Moved permutate function outside of a class.