Doing random permutations to speed up the process.