Changed mysterious wait to a slightly less mysterious while loop