refactor for the good use of promises 10