This loop was not obvious for me until I read it multiple times.
A comment is more than welcome I think.