Fixing caching logic