After a divisive, controversial and surprising presidential election campaign left the country with its most unpopular president-elect in modern history, there has already been much talked about the prospect of Donald Trump not completing his full first term. As a result, the national line of succession, a topic usually reserved for royal families, was arguably more relevant for the presidency than ever.

With talk of Russian election hacking still in the air along with a new suit for defamation, Trump’s inauguration Friday has even been preceded by talk of possible impeachment. Such an outcome would be a first in presidential history, however. While President Richard Nixon may well have been on the way to being impeached, he resigned before it came to pass.

Still, when President Gerald Ford was sworn into office in 1974, he was the most recent of nine vice-presidents to have ascended to the presidency in the middle of a president’s term. Other than Nixon, all were as a result of the president’s untimely death.

If something legal or medical in nature were to befall Trump over the next four years, then Vice-President-elect Mike Pence would be the man to take his place in the White House. Yet, for those concerned by Trump’s hard-right policies, the former governor of Indiana was unlikely to provide any solace, given his staunchly conservative stances on issues like abortion and LGBT rights.

But, while most people will be aware that were something to happen to the president then the vice-president will take the helm, what happens beyond that was less clear. The person who takes the presidency in the event that both the president and vice-president cannot hold office has been subject to change over the course of U.S. history.

The passing of the first Presidential Succession Act in 1792 put the president pro tempore of the senate next in line followed by the speaker of the House of Representatives. They were then removed from the line of succession in 1886, with the president’s cabinet members assuming the responsibilities, before being placed back behind the vice-president when the current line of succession, which includes 18 individuals, was established by the passing of the Presidential Succession Act in 1947.

So under Trump, after Pence, the next person in line would be Speaker of the House of Representatives Paul Ryan. After that comes the president pro tempore of the Senate, the longest-serving senator from the majority party, which is Sen. Orrin Hatch of Utah.

From there, the list goes down the secretaries of the 15 executive departments. At the top of the list of departments is the secretary of state, currently John Kerry, but set to be former ExxonMobil chairman Rex Tillerson under Trump. The last member of the line of succession is the secretary of homeland security.

So far in U.S. history, the line has never had to go beyond the vice-president. However, precautions have regularly been taken in case of a catastrophic event where the leading members of the government are all present. A designated survivor is appointed, who stays away from the event, accompanied by tight security, medical personnel and the country’s nuclear codes to ensure he will be able to take over as president.

While there is no credible terrorist threat, this precaution will be in place for the inauguration Friday. However, with Trump’s cabinet yet to be confirmed, it will be a member of President Barack Obama’s cabinet given the duty.

Given that Obama’s cabinet is set to resign their positions at noon Friday, the prospect that an obscure political figure could become the most powerful person in the world when Trump gets sworn-in will be a reality. If there is no secretary of state in place, the role, according to CNN, would be taken over by the highest-ranking non-political official in the department, currently the Under Secretary for Political Affairs Tom Shannon. That person would assume the position of secretary of state and thus the presidency.

Presidential Line of Succession (If all nominations approved under Trump)

1. Vice-President: Mike Pence

2. Speaker of the House of Representatives: Paul Ryan

3. President pro tempore of the Senate: Orrin Hatch

4. Secretary of State: Rex Tillerson

5. Secretary of the Treasury: Steven Mnuchin

6. Secretary of Defense: James N. Mattis

7. Attorney General: Jeff Sessions

8. Secretary of the Interior: Ryan Zinke

9. Secretary of Agriculture: Sonny Perdue

10. Secretary of Commerce: Wilbur Ross

11. Secretary of Labor: Andre F. Puzder

12. Secretary of Health and Human Services: Tom Price

13. Secretary of Housing and Urban Development: Ben Carson

14. Secretary of Transportation: Elaine L. Chao

15. Secretary of Energy: Rick Perry

16. Secretary of Education: Betsy DeVos

17. Secretary of Veteran Affairs: David J. Shulkin

18. Secretary of Homeland Security: John F. Kelly

Correction: An earlier version of this article listed Sen. Orrin Hatch's state as Ohio. The state he represents is Utah.