Solution to cachematrix