Corrected the exception handling