completed cachematrix code