Check idx after incrementing instead of before so we don't go through another setTimeout before figuring out that we've finished.