Addition of Logic to cache matrix soultion