middlewares for objects and classes