Refactoring caching