Georgia state Rep. Jason Spencer will resign at the end of the month after facing fallout from using racial slurs and exposing himself in a segment on Sacha Baron Cohen’s new Showtime series, “Who Is America?”

“This email/letter is to serve as an official resignation notice to your office that I will be resigning my post effective July 31, 2018,” Spencer wrote to Georgia House Speaker David Ralston late on Tuesday.

Spencer, a Republican, is just one of a number of lawmakers to have been duped into appearing on the series, in which Cohen has gotten public figures to make statements that some have later regretted.

In the episode, which debuted on Sunday, Cohen posed as an ex-Mossad officer, Col. Erran Morad Cohen, who convinced Spencer to take part in a training video. He falls for Cohen’s ploy to say the “N-word,” and at one point he agrees to pull down his pants and scream “America!”

Spencer lost his primary this year, so he was already on his way out, but Ralston and other lawmakers called for him to step down immediately.

In a statement to the Atlanta Journal-Constitution, Spencer apologized and said that “Sacha Baron Cohen and his associates took advantage of my paralyzing fear that my family would be attacked.” Last week, he threatened legal action against Showtime if the segment aired.

In the same episode, former Vice President Dick Cheney signed a “waterboarding kit.” Last week, in the show’s premiere, a group of current and former Republican lawmakers were shown taking part in a faux video promoting the idea of arming kindergarten children.