Refactoring for better DI