Simplified and fixed query