bug fix of matrix