optimize impurity