UniquePermutation final solution together feny's change.