refactoring: use dependency injection