Added middleware for patching the models