fixing issue with promises