fixed diag() defect