updated cachematrix code