Refactoring to make the async package