fix error catching