Update functions to be foldable