Added changes to handle caching scenarios if the data matrix is changed through set function