refactoring : extracted method for easier mocking