finialPermutation optimization added