terminal state machine