wrote functions in cachematrix.R