more documentation and error handling