Ajustments to queryUntil and waitUntil functions