updated error handler