implement cachematrix