fix a bug that causes wrong next state