Btw, note that it is faster to go over y and then x, because then you're looping over the array in the same order in which it is stored in memory. It may not be time-critical here, but it's good to always keep this in mind.