Updated error handler