Implement cache matrix solution