permutation section (permute() & unpermute()) rewrite complete