added compute_next_state private method