Tweaking promise code