Modified cachematrix.R to perform caching