Improved promise-code.

I removed some layers of nesting for the promise-code, hopefully
increasing readability!