Fixed random permutation bug