Used array_pop to respect the order the middlewares are called in. The most top middleware will now be the most outter one.