error handling and documentation