Changed x and y postfix increments to prefix increments in for loops