first middleware implementation