Implemented custom error handler