Added the async if flow function and tests