improve dependency injection code