Added permutation implementation.