Do not use `for` in an inner loop. `while` and `foreach` give better performance.