Just a style comment, but I have a strong (personal) preference to always use braces and newlines with for loops and if statements. I think it helps both readability and avoid bugs.