refactoring away duplication