WASHINGTON Hacked emails show Hillary Clinton’s campaign wrestled with how to announce her opposition to construction of the controversial Keystone XL pipeline without losing the support of labor unions that supported to project.

Emails published this week by WikiLeaks show debate and confusion within the Clinton camp as it faced down the unexpectedly strong primary challenge by liberal Sen. Bernie Sanders, who opposed the pipeline.

As Clinton prepared to come out against the pipeline last year, her aides worried about how her shift in position would be perceived.

Get Breaking News Delivered to Your Inbox

Clinton press secretary Brian Fallon asked in an email whether the candidate’s “newfound position on Keystone” would be “greeted cynically and perhaps as part of some manufactured attempt to project sincerity?”

The emails were stolen from the accounts of Clinton campaign chairman John Podesta, the latest in a series of high-profile hacks that U.S. intelligence officials have blamed on Russia. Clinton has condemned the breaches as an attempt by a hostile foreign government to sway the election in favor of her Republican rival, Donald Trump.

For seven years, the administration of President Barack Obama delayed deciding whether to build the pipeline to carry heavy crude oil from the tar sands of western Canada more than 1,700 miles to refineries on the U.S Gulf Coast. The pipeline had long been a flashpoint in the political debate over climate change, with environmentalists opposing its construction and Republicans in Congress voicing strong support.

As secretary of state, Clinton helped oversee the federal government’s yearslong review of the pipeline’s economic and environmental impact. Asked about the issue in 2010, Clinton said: “We’ve not yet signed off on it. But we are inclined to do so.”

But once she left the State Department and began preparing for her presidential run, Clinton studiously avoided taking a hard position on whether the pipeline should be built. Emails show that throughout 2015, Clinton’s aides were awaiting word on when Obama would come out against the pipeline, offering Clinton a measure of political cover to do the same.

Clinton campaign labor liaison Nikki Budzinski and others warned that opposing the Keystone pipeline might earn the ire of union leaders who supported the pipeline due to the thousands of construction jobs that would be created. Political director Amanda Renteria offered reassurance in an August 2015 email that even if Obama took that position, the campaign could still keep support of the trade unions.

“We are so close to getting bldg trades and if we do this right, it will be ok even though they won’t like it,” Renteria wrote.

Energy adviser Trevor Houser circulated talking points intended to minimize potential political damage. They emphasized Clinton’s broader energy plans for the presidency, which would include infrastructure programs with enough spending and job creation to mollify specific labor groups, including ironworkers, boilermakers and electricians.

“We are trying to find a good way to leak her opposition to the pipeline without her having to actually say it and give up her principled stand about not second-guessing the president in public,” Clinton speechwriter Dan Schwerin wrote.

As the Clinton team prepared to announce her opposition to the pipeline, they heard that Obama had again pushed back his announcement until late October. Clinton aides speculated that the delay was due to political considerations involving the Canadian election, where Liberal Party leader Justin Trudeau was working to oust Conservative Prime Minister Stephen Harper, an ardent Keystone proponent.

Concerned about the primary threat from Sanders, Clinton’s team decided not to wait on Obama. They drafted a statement for her “which uses opposition to KXL as a pivot to talk about a plan for broad investment in modernizing our energy infrastructure and forging a climate compact between the US, Mexico and Canada.”

According to the emails, the planned rollout was designed to “soften the blow to the Building Trades” with scripted language about “making the US the leader in fighting climate change and becoming a clean energy superpower.”

Budzinski provided an update on how efforts to work with various labor unions were going in September 2015.

“Great news that today we received the Bricklayers endorsement coming out of the meeting today. They brought checks today :)“ Budzinski wrote.

She also detailed talks with the national building trades union, saying they appreciated Clinton being “candid and up front with them on a difficult issue like KXL.”

Budzinski added not to worry about reports that the Laborers’ International Union of North America was reaching out to Republicans.

“That is for show,” she wrote.

On Sept. 22, 2015, Clinton appeared at a community forum in Des Moines, Iowa.

“I think it is imperative that we look at the Keystone pipeline as what I believe it is - a distraction from important work we have to do on climate change,” Clinton said. “And unfortunately from my perspective, one that interferes with our ability to move forward with all the other issues. Therefore I oppose it.”

Obama finally announced in November 2015 that the pipeline project would be shelved.

“The right call,” Clinton tweeted in response to the president’s announcement. “Now it’s time to make America a clean energy superpower.”