I hate to say I told you so, but this is one of the reasons why a strong federal govt isn't always such a good idea. It NEEDS to be capable of being challenged in court, AND LOSING BIG.
I mean I don't see any way to stop the President or Congress from editing the rules that they, themselves, make when they are being challenged for illegality, because that's the whole point? I mean the Court's don't usually want to have to challenge these things. I mean the Supreme Court ruling striking down the Civil Rights Act said, essentially, "Hey Congress, you can't just use the exact same rules you wrote in the 60s, go make new ones." and Congress responded "Not now dad I'm too busy yelling at Obama."
Ordinarily, they (Congress and the President) don't change their laws or EOs in response to legal challenges because they went through the effort of making sure it would withstand one, since it's usually inevitable so it's an obvious thing to do (unless you are Trump, or budgetary reconciliation was involved), so whenever they go to the Supreme Court they are willing to defend them because it's not automatically a losing battle. But, again. Half the issue of Trump's EO was that he applied it to Greencard holders, and refused to issue an edited version (which he could have done at any time), instead making the White House Counsel try to claim that that was what the first order did (which the judges didn't buy at all).