implement permutation