Use state machine