Add wait for query completed