add folding code