refactored error handlers