While loops with promises