solution to cachematrix