Modified cachematrix for programming assignment 2