fixing the exception handler