error checking and documentation