split out flow processing to a seperate func