cachematrix.R modified