this looks like .map. Why zipWithIndex.foldLeft?