fixing middleware