docs and error handling