completed cachematrix.R file