added code for cachematrix function