implementing foldleftviafoldright2