Modified error handler