finish pulling out middlewares