Fixed issue with error catching