reformatted error catching