copied refactoring