documentation and error catching