refactoring with test