modified cachematrix to reflect working code