update to cache matrix code