Added caching to query