TikTok faced off with the U.S. government in federal court on Monday, arguing a law that could ban the platform in a few short months was unconstitutional while the Justice Department said the measure is critical to eliminate a national security risk posed by the popular social media company.

Attorneys for the two sides — and content creators — appeared before a panel of three judges at a federal appeals court in Washington, where TikTok and its China-based parent company, ByteDance, are challenging the law that is forcing them to break ties by mid-January or lose one of their biggest markets in the world.

Andrew Pincus, a veteran attorney representing the two companies, argued in court that the law unfairly targets the company and runs afoul of the First Amendment because TikTok Inc. — the U.S. arm of TikTok — is an American entity. Another attorney representing creators who are also challenging the law also argued it violates the rights of U.S. speakers and is akin to prohibiting Americans from publishing on foreign-owned media outlets, such as Politico, Al Jazeera or Spotify.

“The law before this court is unprecedented and its effect would be staggering,” Pincus said, adding the act would impose speech limitations based on future risks.

The law, signed by President Joe Biden in April, was the culmination of a yearslong saga in Washington over the short-form, video-sharing app, which the government sees as a national security threat due to its connections to China.

The U.S. has said it’s concerned about TikTok collecting vast swaths of user data, including sensitive information on viewing habits, that could fall into the hands of the Chinese government through coercion. The U.S. also says the proprietary algorithm that fuels what users see on the app is vulnerable to manipulation by Chinese authorities, who can use it to shape content on the platform in a way that’s difficult to detect.

Daniel Tenny, an attorney for the Justice Department, argued in court that data collection is useful for many companies for commercial purposes, such as target advertisements or tailoring videos to users’ interests.

“The problem is that same data is extremely valuable to a foreign adversary trying to compromise the security of the United States,” he said.

Pincus, the attorney for TikTok, said Congress should have aired on the side of disclosing any potential propaganda on the platform instead of pursuing a divesture-or-ban approach, which the two companies have maintained will only lead to a ban. He also said statements from lawmakers before the law was passed show they were motivated by the propaganda they perceived to be on TikTok, namely an imbalance between pro-Palestinian and pro-Israel content on the platform during the war in Gaza.

But the panel — composed of two Republican and one Democrat appointed judges — expressed some skepticism, pressing the attorneys on TikTok’s side if they believe the government has any leeway to curtail an influential media company controlled by a foreign entity in an adversarial nation. The judges also asked if the arguments presented would apply in cases where the U.S. is engaged in war.

Judge Neomi Rao, who was appointed by former President Donald Trump, said the creators suing over the law could continue speaking on TikTok if the company is sold or if they choose to post content on other platforms. But Jeffrey Fisher, their attorney, pushed back, arguing there are not “interchangeable mediums” for them because TikTok is unique in its look and feel, and the types of audiences it allows creators to reach.

In the second half of the hearing, the panel also pressed the Justice Department on First Amendment challenges to the law.

Judge Sri Srinivasan, who was appointed by former President Barack Obama, said efforts to stem content manipulation through government action does set off alarm bells and impact people who receive speech on TikTok. Tenny, the attorney for the DOJ, responded by saying the law doesn’t target TikTok users or creators and that any impact on them is only indirect.

For its part, TikTok has repeatedly said it does not share U.S. user data with the Chinese government and that concerns the government has raised have never been substantiated. In their lawsuit, TikTok and ByteDance have also claimed divestment is not possible. And even if it was, they say TikTok would be reduced to a shell of its former self because it would be stripped of the technology that powers it.

Though the government’s primary reasoning for the law is public, significant portions of its court filings include classified information that has been redacted and hidden from public view.

In one of the redacted statements submitted in late July, the Justice Department claimed TikTok took direction from the Chinese government about content on its platform, without disclosing additional details about when or why those incidents occurred. Casey Blackburn, a senior U.S. intelligence official, wrote in a legal statement that ByteDance and TikTok “have taken action in response” to Chinese government demands “to censor content outside of China.”

Though the intelligence community had “no information” that this has happened on the platform operated by TikTok in the U.S., Blackburn said there is a risk it “may” occur.

The U.S. has said it’s not required to wait until something detrimental happens before responding to the threat, but the companies have argued the government could have taken a more tailored approach to resolve its concerns.