add documentation and refactor