Working implementation using caching