refactoring to async implementation