revised for recording previous step output.