Refactored so that network calls are async.