clean up the error checking