fixed state transition code