fixing diag() calls