update cache matrix function