Refactoring duplicate code.