Converted grid from 2D array to plain array