Implemented cachematrix