more duplication refactoring