Fixed error when there is no existing middlewares.