refactoring
used promise