change the stopping function