Refactored code in onCollectionUpdate method of the interceptor