improved cacheInjectMethods method