Fix firing event inside promise callback