permutations unique reimpl