added cache, optimized queries