change the grid from being double array to  single array, also changed the tests