altered cachematrix.R function