changed the exception handling