correct-ize the caching logic