reverted bf5b826
Rewrote error handler