accept any function as middle handler