Moving `handler()` out of `promise.then()` and into `promise` so it can be cached