more extensive error checking