You gotta love this twisted logic.

In May, a federal appeals court declared the National Security Agency's bulk telephone metadata collection program illegal because it wasn't authorized under the Patriot Act, as the Obama administration and its predecessor administration had maintained.

Then, in June, Congress semi-dismantled the program with the passage of the USA Freedom Act, which President Obama signed on June 2. As part of the new act, Congress authorized a spying transition period of sorts where the old tactics could continue until new laws were in place.

But on Thursday, the same federal appeals court that originally declared it "illegal" now said the original NSA program could continue, beating back a challenge from the American Civil Liberties Union that questioned both the transition period and the constitutionality of NSA surveillance overall.

In case you've forgotten, here's what is at stake: Under the program that former NSA contractor Edward Snowden disclosed, the nation's telecoms forward data to the National Security Agency, including the phone numbers of both parties in all calls, calling card numbers, the length and time of the calls, and the international mobile subscriber identity (ISMI) number for mobile callers. The NSA keeps a running database of that information. The NSA says it queries the data solely to combat terrorism and that one party of a call must be believed to have been overseas.

So how could something so seemingly unconstitutional continue? Congress said it could, that's how.

With the passage of the USA Freedom Act, Congress extended the program that Snowden exposed for another six months to allow for an orderly transition to the new snooping program. And now the courts essentially maintain that the original surveillance is legal because Congress says it's legal.

"An abrupt end to the program would be contrary to the public interest in effective surveillance of terrorist threats, and Congress thus provided a 180-day transition period," 2nd US Circuit Court of Appeals Judge Gerard Lynch wrote for the unanimous three-judge panel. "Under the circumstances, we will defer to that reasonable decision."

This matters because whether the NSA, lawmakers, or the administration will construe some other law to allow the original, secret bulk collection program to continue is anybody's guess. Meanwhile, although the original spy program as disclosed by Snowden has been dramatically altered by Congress, there will continue to be a lot of authorized warrantless phone spying done by the NSA on Americans after the six-month extension expires.

Under the new legislation, the bulk phone metadata will stay with the telecoms and will be removed from the NSA's hands. It can still be accessed with the secret FISA Court's blessing as long as the government asserts that it has a reasonable suspicion that the phone data of a target is relevant to a terror investigation and at least one party to the call is overseas. The Constitution's Fourth Amendment standard of probable cause still does not apply.