refactoring and documentation