Fixed loops in query methods