Updated cachematrix() function for R Prog assignment 2