fix diagonalization