fixed error catching