refactoring+testing