modified cachematrix.R script