better section folding

simpler code + move specific logic out of fold.js