added the stopping at M_max program