created flow_function.R for better simulations of flows