routes and middlewares fix