fix Promise algorithm.