add some error checking