rework to use duplex and simple pipes