refactor to dispatch_group
implement promise.then