refactored dependency injection