implemented cachematrix