complete 2 cache matrix function