added functions for inflow and outflow