Threads now loop through all available queries