Solve bug for gen_pivot()