refactor for promised