demo using state-machine