Finished (?) permutation function