Just write a state machine and call it a day