fix a bug from folding in wrong direction