modify next_permutation