Completed cachematrix code