fixed promise bug