Refactor fixed state machine example