mergeFlows() function added