Modified cachematrix.r to invert matrices and cache them