refactoring and commenting existing code