Fix error in Middleware

Fix error where object was being used as an array