move error handling to pipe