adding error handler