Added permutation table logic and associated test.