Switch from matrix (which is immutable) to an array of arrays to represent the grid