fix next() usage in middleware.