added error handler.