add some error trapping