#4574 improved query