Made changes to decide_next. Not yet tested.