Renaming the global matrix to "cachedMatrix" to avoid confusion with local variables.