documentation and error checking