piping the heads and tails