and more complete error checking