Implementing a finite-state machine using async/await