rewrite promise then as anonymous function