The problem with something like if (j == 7) is the situation when the 7th request is very very fast, and even one of the others is slow. Even though you have queued it up last, it might not be the last to complete.
This answer seems to work for all conditions:
https://stackoverflow.com/a/3709809/813154