Fix nextPermutation if it's last