Replacing bad error catching code