Fix the exception handling