make pipeline into a first-class object that can store state