I actually started from the original code and not the one in this PR, so some variables might be wrong. I'll try it to change it in your branch.

It would look better using the Async functions, but I don't think that we can use them when we don't know how many requests we need to do.