wrote code for cachematrix.R script