slightly more error checking