I think we should fix this complete nested loop by moving lines 111-113 before the `x` loop in the `y` loop.
this would allow us to loop from `x=0 to x < size.x()` and we do not need the `-1` anymore. And there would be no `if (x==0)` condition.