added impurity updating