pass in functions as middleware