Optimized queries 3 and 4