Replace static code with dependency injection