fixed promise assignment issue

variables assigned to in the `then` callbacks weren't declared