added basic function of middleware