fix bug when original matrix was changed