fixed a bug with the reference of the matrix const iterator