foldLeft impl