ADMIT it. The world’s commentators, Banyan included, have underestimated North Korea’s leader. Kim Jong Un was preparing this week to meet South Korea’s president, Moon Jae-in, on the southern side of the demilitarised zone between their two countries, on April 27th, just after The Economist went to press. Even six months ago, no one imagined Mr Kim capable of leading a diplomatic dance that has drawn in not just South Korea but America and China. He is proving to be an adept young dictator.

This week’s summit is due to discuss a formal peace treaty that has eluded leaders of North and South Korea since the Korean war ended in an armistice in 1953, entrenching the bitter division of the peninsula. It is also meant to pave the way for a summit between Mr Kim and President Donald Trump, in late May or early June at a venue that has yet to be announced.

Some still rub their eyes at the prospect of the first-ever meeting between a North Korean leader and a sitting American president. At the end of last year the two countries appeared on the brink of conflict. But Xi Jinping, China’s president, took the prospect of a Kim-Trump love-in seriously enough to roll out the red carpet for Mr Kim when his armoured train made an unexpected visit to Beijing in late March. It was Mr Kim’s first trip abroad as leader. Until that point, his nuclear shenanigans had so angered China that its relations with North Korea, a supposed ally since China came to the North’s rescue during the Korean war, were at their worst in memory.

Never gonna give you up

The surprises continue. Mike Pompeo, Mr Trump’s hawkish CIA director (and next secretary of state), called secretly on Mr Kim over Easter, suggesting that the administration and the North Korean regime are now talking at the highest levels after years of next to no communication. More strikingly, on April 20th Mr Kim declared an end to all nuclear and long-range missile tests.

Never mind that there had been no test activity for a while. The declaration wowed the one audience it was intended to impress, when Mr Trump declared on Twitter that this was “big progress!” The outlines of the kind of deal Mr Trump hopes for are becoming clearer. A peace treaty—to which the United States and China, as signatories to the armistice, would have to agree—might provide the reassurances the North Korean regime wants over its security. In return, Mr Kim would take (as yet unspecified) steps towards denuclearisation. And America would secure a loosening of the international sanctions on the North.

The trap for Mr Trump, in all likelihood, is that Mr Kim probably has no intention of giving up his (growing) nuclear arsenal. If that is so, the scheme was hatched months ago. November marked the height of tensions on the peninsula. That was when North Korea conducted its third test of an intercontinental ballistic missile, and when talk in Washington was of giving Mr Kim a bloody nose. Perhaps, observers murmured, Mr Trump really was reckless enough to risk a second Korean war.

Yet right after the test, and little remarked, Mr Kim declared the fulfilment of a sacred national goal, the completion of a “state nuclear force”. The flurry of launches suddenly ceased. Mr Trump claims that his sanctions and threats brought Mr Kim to the table. But since that declaration it is Mr Kim who has set the diplomatic tempo and selected the mood music—literally so, when he invited K-pop bands from South Korea to Pyongyang, his capital.

Given such canniness, a reassessment of the rest of Mr Kim’s rule is overdue. He took power at the age of 29, 28 or 27, depending on whether you believe the North, the South or America, after his father, Kim Jong Il, died of a heart attack in late 2011. The Swiss-educated brat hardly seemed cut out to be a dictator. The Economist described him as callow. Prominent figures from his father’s inner circle appeared to hold much power. Mr Kim enjoys a cushy life, living in palaces and having a whole nation goose-stepping at his command. But he cannot sleep easy. If he were ever to lose power, he would doubtless meet the same fate as Muammar Qadaffi. He will do anything to avoid that. Both his grandfather, Kim Il Sung, and his father acquired senior posts when they were young, and both died of natural causes.

The lineaments of Mr Kim’s rule appear consistent: purges and repression at the highest level, economic liberalisation at the grassroots and the pursuit of nuclear weapons. From the start he set out to eliminate threats, not least by executing his uncle, Jang Song Thaek, in 2013 and having his elder brother, Kim Jong Nam, assassinated in a Malaysian airport last year. Constant purges of the army’s upper ranks seem designed to forestall hostile factions. Mr Kim, says Andrei Lankov of Kookmin University in Seoul, is a deft dictator: “smart, calculating and cruel—yet not sadistic for the hell of it.” (That must be scant comfort for all the innocent prisoners being beaten with hammers in his gulag.)

His strategy, as Mr Lankov puts it, is to fill hearts with fear and bellies with food. From the start Mr Kim has encouraged petty capitalism, in contrast to his father. Private trade is rarely persecuted these days. State enterprises have won autonomy, or in effect been privatised. From a low base, the scope for a decrepit economy to grow is considerable.

Don’t underestimate the importance at home of Mr Kim’s third plank, his nuclear capability. It is the crux of his domestic propaganda, and the army’s prestige rests on it. Since he probably fears his own generals more than America’s, there is reason to doubt that Mr Kim would ever trade his nukes away. Yet sanctions are starting to bite. Mr Kim seems to intend to switch emphasis, from acquiring nuclear arms to developing the economy. For that he needs the summits, and to keep Mr Moon, Mr Trump and Mr Xi dancing. It is unclear how the dance will end. But what is certain is that he will have rehearsed the steps more carefully than they have. After all, Mr Kim has more at stake.