replaced condition checks with exception handling