Uncomment middleware

Fixed the traceback in middleware