Added permutations function