remove the 2D array and use array of ptr