Edited cachematrix script