added permutation function