Replace 2-dimensional array with 1-dimensional array consisting of chars