refactoring: code duplication