refactoring and docs