a lite state machine implementation