put in some error checking