modified ControllerMiddleware