Mike Pompeo took over a badly bruised State Department in late April. Under his predecessor, former ExxonMobil chief executive Rex Tillerson, morale had taken a serious dive. Tillerson dreamed of reorgan­izing America’s diplomatic hub in the name of corporate efficiency and ended up publicly humiliated by his boss, who fired him via Twitter.

Just four months into his tenure, Pompeo is earning measured praise from State Department veterans and critics of the president alike for his efforts to empower the diplomatic corps. The secretary, while trying to return his department to regular order, has also maintained the confidence of a highly irregular commander in chief.

“Secretary Pompeo has the difficult challenge of reconciling the president’s often mercurial forays into foreign policy with the need for a systematic implementation of foreign policy that maximizes U.S. influence,” says Jeff Rathke, a former State Department official who now serves as president of the American Institute for Contemporary German Studies.

Pompeo must dodge-and-weave between tweets that could throw a wrench in diplomatic plans. He must be eloquent and forceful on television—which his boss is likely watching. He must also try to work with allies who often wholeheartedly disagree with the paths being forged by Trump.

“He is still ultimately stuck playing catch-up with the president. This is fundamentally the problem,” says Ilan Goldenberg, a senior fellow at the Center for a New American Security and a former Obama administration foreign policy official. “You can be a pretty good manager, you can hire good people, you can have some policy instincts on some things, but the president is going to go off and tweet.”

Pompeo has kept his cards close on any disagreements with Trump, unlike his predecessor, who publicly split with the president on issues like the Iran nuclear deal. Pompeo has also been a steadfast defender of Trump, even during Senate hearings when grilled on issues like the split between the president’s wavering rhetoric on Russia and the administration’s strong actions. Critics agree that the president’s unpredictability generally ends up undercutting the efficacy of the State Department. Pompeo’s “got Jim Jeffrey and Brett McGurk and Joel Rayburn. That’s a good team on Syria and ISIS,” says Goldenberg. “But all they do is spend all their time trying to convince the president that he shouldn’t withdraw from Iraq and Syria.”

Tillerson faced similar presidential and policy challenges. But he also had to deal with plunging morale among the diplomatic corps spurred by his desire to “redesign” the department. Pompeo learned from these managerial mistakes. “When your first act in office is to stop the beating, morale has to go up,” says Ronald Neumann, a three-time ambassador who is now president of the American Academy of Diplomacy.

As Tillerson aspired to an 8 percent personnel cut at State, he oversaw a hiring freeze that initially affected family members of Foreign Service Officers seeking work in embassies overseas. “It was a 15-month period of extraordinary destructiveness to the ranks of the Foreign Service,” former ambassador to the United Arab Emirates Barbara Leaf told CBS. “There was a forced exodus of a lot of very fine public servants.”

Pompeo lifted the foreign and civil service freeze during his first few weeks on the job and has worked to fill many of the open slots in the department. He has also appointed well-respected special envoys to North Korea and Syria—a reversal of Tillerson’s efforts to eliminate such positions. Vacancies remain. Of senior leadership and ambassadorial positions, more than 50 are pending in the Senate, according to figures provided by the State Department. More than three dozen positions requiring Senate approval remain vacant with no nominee, according to the Partnership for Public Service. “Unwinding the damage is very difficult,” says Neumann. “They’ve begun to do it, but they have limited flexibility. It’s time-consuming and awkward.”

Pompeo has also returned the State Department to a more traditional decision-making process, rather than the micromanagement that Tillerson preferred. “Tillerson was famously isolated from the broad mass of the State Department,” says Rathke. “Pompeo has taken steps to involve a broader cross-section of the department in the work of policy formulation and implementation.”

The secretary’s public synchronicity with the president gives the State Department an air of credibility it never had under Tillerson. “When Secretary Tillerson spoke, you were always fearful that what he said would be contradicted within days, if not hours, by the president and his Twitter account,” says Antony Blinken, who was deputy secretary of state for the last two years of the Obama administration. “There’s a greater feeling around the world that when Secretary Pompeo speaks, he is speaking for the president.” “The building feels more relevant and more empowered,” Blinken says. “When their boss has the president’s ear, that’s how they have the president’s ear.”

Pompeo has taken steps to show that he cares about the department and its mission. “He’s done town hall meetings when he’s stopped through on important visits overseas,” Leaf told CBS. “Not every secretary does that, actually. Many of them don’t. They don’t make that one gesture which kind of tells the troops, ‘Hey, you’re my troops, I’m looking out for you.’ ”

Pompeo fiercely pushed back against a proposal by the Office of Management and Budget to rescind billions of dollars in unspent foreign aid, the Washington Post reported in August. Tillerson had agreed to a proposed 30 percent budget cut (which was ultimately rejected angrily by Congress). Pompeo won’t accept the 10 percent cut OMB was suggesting; he sees the funds as essential to his mission.

In his first four months at Foggy Bottom, Pompeo has time and again said he wants to move the State Department to the fore of the Trump administration’s foreign policy. “We’re going to get our swagger back,” he said in May. “The State Department will be out in front in every corner of the world leading America’s diplomatic policy, achieving great outcomes on behalf of President Trump and America.”