modifed on cachematrix.R