implement permutations