Fix promise bug