refactor the caching