fix bug in promise handling code...