first try of diagonalize