Changed to using a 2D array to store the grid data