initialPermutation optimized (hopefully)