still not sure if the caching logic is correct