Moved the exception handling to a more opportune location