Refactored function afs_add_flow (split function by flow type)