completed assignment for cachematrix function