Refactored permutation
Refactored permutationsd