coding the matrix : fix : index out of range
coding the matrix : bug fixing