Completed example with caching