add error handlers before pipe not after