cachematrix function with more comment