updated move grid to not crash if near the edge of the map