next permutation modified