attempt to fix bugs in folding