fixed bad caching logic