Improved dependency injection implementation