fixing error catching