Implemented Cachematrix.R code