Extract folding component
Give index to fold function