Extract permutation function