fixed error handling defect