modify the middleware and add function to process the slug