fix bug with promises