Emulate how Finite-state machine works.