add logic to cachematrix.R