JSHint thinks `promise` here is a global. I haven't reviewed in detail to see where it is coming from...