Sen. Ted Cruz (R-Texas) attempted to school career federal prosecutor Sally Yates on the law, and it did not go well.

Yates, who served as acting attorney general for 10 days of President Donald Trump’s administration before she was fired for refusing to defend the president’s controversial ban on travel from certain Muslim-majority countries, appeared on Capitol Hill Monday to testify before the Senate Judiciary Subcommittee on Crime and Terrorism.

While the hearing was focused on Trump and his associates’ alleged ties to Russia, some senators, including Cruz, instead focused on Yates’ refusal to defend the president’s executive order.

While questioning that decision, Cruz, also a lawyer, cited a portion of U.S. code that allows the president to block immigrants from entering the country if allowing such entry would be “detrimental to the interests of the United States.”

Yates immediately fired back by citing another statute that says visas cannot be denied due to someone’s race, nationality or place of birth.

Watch the exchange above.

Read more on the hearing here.