more error handling, update documentation