refactor and docs