better pipeline handling
add a unit test