documentation and refactor