Fixed foldexpr function