Simple State Machine Implementation