promise refactor