Revised cachematrix program for ProgrammingAssignment2