Making the diagonalization routing a function on its own.