Fixed middleware problem