change code for matrix