refactor and document