changed pieces array to a 1-dimensional array