crafting the perfect query