changes to the cachematrix function