Bernie Sanders’s rise to front-runner status in the Democratic primary has prompted renewed scrutiny of favorable statements Sanders made about socialist dictatorships in the 1980s (comments he has since defended) and, in particular, his 1988 trip to the Soviet Union.

Sanders’s critics complain that the senator’s compliments of certain aspects of the Soviet Union ignore and minimize that country’s horrible crimes. However, the story is more complicated than they acknowledge. The Soviet Union of 1988 was no longer the Stalinist dictatorship it once was, nor was it even the Brezhnev-era oligarchy that preceded it. Rather, Sanders’s trip to the U.S.S.R. came when the country under Mikhail Gorbachev was taking radical steps to democratize, and U.S. leaders on both sides of the aisle were encouraging such changes. Understood in this context, Sanders’s remarks show a desire to challenge stereotypes and end the Cold War — not support for authoritarianism.

Beginning in the late 1970s, the Cold War dramatically hardened, reversing thaws of the prior decade. Clashes over the Soviet invasion of Afghanistan, human rights and arms control brought the Soviet Union and the United States to the brink of military confrontation. Ronald Reagan adopted a hard-line strategy to what he labeled “the evil empire”: Even when he wanted to ease tensions, Reagan found himself without a negotiating partner thanks to a rapid succession of aging Soviet leaders.

But with the rise of Gorbachev in 1985 came dramatic transformation. Gorbachev was ready to cast off years of orthodoxy at home and abroad. The new Soviet general secretary was eager to resume dialogue with the United States to both improve the security of the U.S.S.R. and to create room for what would turn into a radical set of domestic reforms.

During the next few years — in fits and starts — Reagan and Gorbachev were able to come to an understanding on a number of issues, including nuclear weapons. In 1988, Reagan even visited Moscow, and he admitted to a journalist that he no longer thought of the U.S.S.R. as an “evil empire.”

This admission was important because the future of the Soviet Union was very much unclear at the time — no one could foresee its rapid disintegration over the next few years. Reagan understood that for peace to succeed, the American public would have to look at the Soviet Union in a new way — and that such a view was warranted, despite criticism from hard-liners in his own party.

Gorbachev was working to transform the Soviet economic and political system. He took steps to liberalize its strict planning system and to legalize small businesses, and he launched his glasnost doctrine, which removed the draconian censorship system.

Most importantly, in 1988, Gorbachev won a constitutional reform that created a new supreme legislature called the Congress of People’s Deputies. Unlike its predecessors, this legislature would have representatives elected by popular vote. While a majority of the Congress was either stocked with representatives directly appointed or nominated by the Communist Party, dissidents such as Andrei Sakharov were also elected. Boris Yeltsin, increasingly critical of Gorbachev for not reforming things even more rapidly, also beat а nominee supported by the party establishment. These non-Party representatives criticized the Soviet government on live television — something unimaginable in an earlier period.

For observers in the West and in other communist countries, Gorbachev was not a strongman, but a leader trying to democratize his country against significant conservative resistance. It is no wonder that East German protesters who feared their government would violently crack down on them chanted “Gorbi save us” on his 1989 visit to the German Democratic Republic.

“People-to-people” contacts had been an important part of Soviet (and American) policy since the 1950s, but in 1988, they dovetailed with the Reagan administration’s efforts to cool the Cold War and guide the U.S.S.R. toward a more humane path.

It is in this context that we must understand Sanders’s trip to the Soviet Union. While clearly sympathetic to leftist regimes and an opponent of Reagan, Sanders ventured to the U.S.S.R. at a moment bursting with promise. The Soviet Union seemed to be undergoing a radical transformation that not only promised to end the horrors of the Cold War, but also to transform the authoritarian countries of the Warsaw Pact into humane, social democratic countries that resembled Sweden more than they did Stalinism. Indeed, many of Gorbachev’s more progressive advisers and confidants openly hoped the U.S.S.R. would slowly transform into some middle way between state socialism and free-market capitalism.

In fact, what seemed to interest Sanders most during his trip was the palpable excitement about change and interest in politics that he encountered. Immediately upon his return to the United States, Sanders participated in a panel discussion where he described the quality of Soviet housing as “not good,” but applauded its affordability, expressing appreciation that in the U.S.S.R. people were only paying 5 percent of their income on housing. He saw this as contrasting favorably to ballooning housing costs in the United States and approximately 735,000 people suffering from housing insecurity and homelessness.

Some would say that such a comparison is precisely the problem with Sanders’s remarks. But his recognition of the social reforms and the functioning and relatively comprehensive safety net that existed in the Soviet Union has been vindicated by scholars who have delved into Soviet history since the end of the Cold War. Scholars continue to document the authoritarianism, brutal repression, horrific inequality and massive crimes of the regime, including the famines in Ukraine and Kazakhstan, the Great Terror and the deportation of Baltic people after World War II. But they have also gained newfound appreciation for how the U.S.S.R. tried to live up to its ideals on questions of equality, and how it offered its citizens a form of state-funded welfare that was, by the late 1980s, in short supply in the United States.

Moreover, it was a society that changed over time. The U.S.S.R. of 1988 was not the Stalinist horror of 1937 no more than the United States today is the same country that enslaved millions of people.

For historians of the U.S.S.R., therefore, there is nothing particularly controversial about Sanders’s trip or his comments, which align quite neatly with the story told by historians who study the late Soviet and Gorbachev years. Any quality Soviet history class today includes the unique horrors of Soviet history, but also contextualizes the Soviet project as one of many 20th-century experiments with different kinds of policies, ideas and approaches to solving large-scale problems such as poverty and inequality.

The understanding that the Soviet Union was pure evil, and demanded 100 percent condemnation, which underpins some criticisms of Sanders’s remarks, stemmed from the way that the superpower conflict shaped domestic consensus in the United States. The Cold War depended on public understanding of the Soviet Union as an implacable enemy and an existential threat. Politicians, journalists, filmmakers and educators all participated in this framing of the conflict to justify military spending and the loss of American lives fighting battles against communism. But such hard-line framing had profound negative effects, ranging from McCarthyism to the lack of flexibility in foreign policy that spawned the disastrous Vietnam War. For scholars of foreign policy, therefore, the blowback over Sanders’s desire for greater understanding between Americans and Soviets is a reminder of how hard it can be to dismantle such images, and yet how important such work is to understanding the costs.