updated cachematrix code for assignment 2