Added adapted pivot choose.
Fixed stack overflow issue on big data