fix bug and add promise