Fixed bug in error_handler