fixed bug in middleware handeling