updated cachematrix - tested