Fix for 404 middleware