updated cachematrix.R as per instruction