fixed error trapping

fixed error trapping