Updated to refactor exception handling