adding the code for cachematrix