Fix loading middleware