final version of completed cachematrix.R file