update to permutation and optimization