A tiny state machine