rewriting with promises