refactoring with async