Refactoring : duplicate code removal