refactoring with dep. injection