Let's write a state machine abstraction together to understand it better