code refactoring and documentation