refactored caching layer