foldl
update example with foldl