refactored 2 code duplication smells