working on 3 state Finite State Machine