bug fix on promise handling