changes in cachematrix function