moving errors to error handler