This could probably be extracted to a private function that accepts as args the vars it currently references through closure.

Not a show stopper, but may help performance a tiny bit since the JS runtime won't have to rebuild the wrapping function as well for each call to `then()`.