Added fix for y offset

There was a small offset in the y direction, fixed by iterating over the y offsets in the same way as the x offsets.