Added permutation function