Factor out some replace chain logic
Factor out some replace chain logic

Splitting up `constructChain` should help readability. There's no
change in behaviour here.

clample/lambdabtc,clample/lamdabtc,clample/lambdabtc,clample/lamdabtc