added additional error trapping