Fixed a bug in folding function