A federal judge accused the Trump administration of “running out the clock” on the president’s four-year term to avoid granting work permits to hundreds of thousands of undocumented immigrants known as Dreamers.

U.S. District Judge Nicholas G. Garaufis, in Brooklyn, said at a hearing Wednesday that the government should have resumed accepting new applications for Deferred Action for Childhood Arrivals (DACA) when the U.S. Supreme Court blocked the administration from terminating the Obama administration program in June.

Instead, he said, the Department of Homeland Security’s acting secretary, Chad Wolf, issued a memo in July that restricted access to the program, a move Garaufis called “sad” and an “inappropriate use of alleged executive authority.”

“You are not entitled to manufacture your own law,” Garaufis said. “I’m deeply disappointed that that appears to be the situation.”

Garaufis had ruled Saturday that the Trump administration illegally appointed Wolf to the top DHS post last year, engineering a new order of succession and leapfrogging other officials who traditionally should have been in line for the job. The judge ruled that Wolf’s subsequent memo effectively declining to restore the original 2012 DACA program — such as taking new applications for the first time in three years — was invalid.

Wednesday’s hearing was supposed to allow the court to consider next steps in the case, but Garaufis signaled that time was running out.

The incoming Biden administration already has pledged to fully restore the DACA program, which grants work permits to eligible undocumented immigrants who entered the United States as children.

Advocates for immigrants say Wolf’s memo affected as many as 1.1 million people, including more than 640,000 immigrants currently enrolled in the program and who are allowed to renew their work permits. Wolf’s memo reduced the permits’ validity from two years to one.

Gaby Hernandez, an undocumented immigrant, talks with supporters outside the U.S. Supreme Court in June.

Several federal judges and the Government Accountability Office have raised concerns about the Trump administration’s practice of catapulting “acting” officials into key roles, thereby sidestepping federal laws. President Trump has said he prefers the acting role because it grants him “flexibility” to hire and fire.

Lawmakers say it is unstable to have key leaders who have not gotten Senate confirmation, especially at DHS, a massive agency created after the 9/11 terrorist attacks to protect national security. DHS has not had a Senate-confirmed leader in nearly 600 days, the judge said in his ruling Saturday.

DHS officials have said that attempts to declare Wolf’s appointment unlawful are “baseless,” and they criticized Garaufis, who was appointed during President Bill Clinton’s administration, as an “activist judge” after last week’s ruling.

Garaufis said the Trump administration has repeatedly violated the order of succession requirements laid out in the Homeland Security Act.

Christopher Krebs, the former director of the Cybersecurity and Infrastructure Security Agency (CISA) who led state and local election officials in protecting their systems during the general election earlier this month, should have become acting DHS secretary last year instead of Kevin McAleenan, the judge said.

“Ironically, Mr. Krebs was fired just last night,” Garaufis said at the hearing, adding that Trump booted Krebs “after he apparently successfully led the effort to protect the security of the November 3 election.”

Wolf replaced McAleenan as acting secretary in November 2019, and he has been considered a Trump favorite.

The DACA lawsuit also revealed that Peter T. Gaynor, chief of the Federal Emergency Management Agency, briefly assumed control of DHS in September — and again on Saturday — to issue succession orders to “reconfirm” that Wolf was lawfully appointed.

Then Wolf ratified his past policies to ensure they would have legal standing.

Chad Wolf, acting homeland security secretary, appears before the Senate Homeland Security and Governmental Affairs Committee in August.

DHS said it maintains that Wolf was lawfully appointed and that the department made the succession moves “out of an abundance of caution and to minimize any potential disruption.”

“The department continues to evaluate its legal options in these cases and is working to ensure the administration’s challenged policies and regulations remain in effect,” the agency said.

The move appeared to irritate Garaufis, who had already ruled that Gaynor could not serve as secretary just for the “sham purpose” of securing Wolf’s position.

Garaufis told lawyers in court Wednesday that the “little exercise” would not work. A Justice Department lawyer responded that the memo was not intended to affect the judge’s ruling in the DACA case.

A spokesman for Rep. Bennie Thompson (D-Miss.), chairman of the House Homeland Security Committee, said the committee was not informed that Gaynor took over DHS on Saturday, however briefly.

On Twitter, Thompson called the situation “a mess.”

“DHS’ latest legal gymnastics won’t change the fact that department leadership made a massive error over a year ago in improperly designating an acting secretary and still can’t manage to fix it, as desperate as they are to preserve their terrible policies,” Thompson said in a statement. “Thankfully we will have better stewards of the department in just two short months.”