changed signature of method nextState