documentation and refactoring