update permutation function