trying to add some error checking