Updating cachematrix program to perform as required