modified cachematrix for assignment