Reimplemented using async/await.