it works with permutations