Fixed middleware issue