Friday is the fortieth anniversary of the U.S. Department of Energy, and reflecting on four decades of the agency’s track record offers guidance about what its next forty years might look like. And right now, one could say the agency is at crossroads.

The DOE was born in the seventies in response to two sets of problems: 1) an intensive Cold War pressure to maintain, expand, and improve the stockpile of nuclear weapons, and 2) the oil crises triggered by supply cutoffs from oil-producing nations. Two prevailing mindsets—that the nuclear arms race with the Soviet Union would never end and that oil and gas were scarce and running out—drove the agency’s formation. Decades later, things have changed.

The Atomic Energy Commission, a civilian agency responsible for nuclear weapons, became the backbone around which the department was formed. While treaties to reduce the number of nuclear weapons took root during the Reagan administration, the mission of the DOE is still primarily related to nuclear weapons development or management. To this day, you might say the department is still a nuclear weapons agency that dabbles in energy on the side. Of its seventeen national labs, only two—the National Energy Technology Lab and the National Renewable Energy Lab—actually have the word “energy” in their names.

But what it has done with energy has left us in a stronger position and portends an even larger and more relevant role as the world contemplates a transition to cleaner, domestic sources of energy.

The most important lever that the DOE controls is research and development, or R&D, investments through national labs and grants to outside institutions. Despite some high-profile, expensive failures such as trying to make liquid fuels from coal, our national innovation system—a public-private-academic partnership—is what should drive the future.

A study by the National Academies of Sciences and Engineering concluded that the first twenty years of R&D investments by the DOE generated economic savings and environmental benefits that far outweighed the costs, in particular from energy-efficiency improvements to ubiquitous appliances such as refrigerators. Investments in solar and wind have helped trigger innovation pathways that helped prices to fall 80 percent or more. And DOE-sponsored R&D that helped kick-start the shale revolution helped cut oil imports dramatically and turn the nation into a natural gas exporter.

Moving forward, despite allegations that the Trump administration is not interested in its fate, the DOE could remain as relevant as ever for a mix of Republican and Democratic priorities. It can use its portfolio to focus on the more pressing future challenges: the risks of global climate change and fostering economic growth in an uncertain world.

Although the modern emphasis is to maintain or reduce, rather than expand, the nuclear stockpile, national lab experts remain critical to efforts to combat weapons proliferation and to mitigate nuclear threats from bad actors. And the international imperative to decarbonize our economy means that the DOE should continue its world-leading role in basic science and research and development. It should foster innovation for capturing and sequestering emissions from fossil-fuel systems, designing new reactors that keep nuclear energy part of the fuel mix in a safe way, and creating better energy storage or management schemes for integrating renewable energy at greater fractions.

The department’s first forty years were dominated by investments in increasing energy supply from a range of energy sources. Given their economic and environmental benefits, the next forty years should focus on decreasing energy demand by accelerating the adoption of efficient appliances and devices. And DOE labs, which house the world’s fastest computers, should lead the charge in partnership with universities and businesses on developing artificial intelligence and machine-learning approaches that will have broad applicability to other sectors such as health care and traffic management. Switching from supply-side energy research priorities to smart and demand-side approaches would have the most desired effect.

The past forty years have given us a positive legacy of increasing energy supply and lower prices. The next forty can be where we as a nation turn toward smarter energy management to maintain those gains while reducing environmental impacts.

Michael E. Webber is the deputy director of the Energy Institute at the University of Texas at Austin. His book Thirst for Power: Energy, Water and Human Survival was published by Yale University Press in 2016.