Fix promise handling