See comments for the async version above.