added some error checking as I track down a problem in another project