better documentation and error handling