move adding the middleware to the application file