Replaced previous reverse and usages with foldLeft version