Add documentation
Add log and refactor