breaks out of loop if too many queries