solve a lot of mistakes with do_pivot method