implemented foldLeftViaFoldRight