A 26-year-old California man has lived to tell the tale of how doctors actually pulled a tapeworm out of his brain.

As CBS San Francisco reported, Luis Ortiz’s story began when he visited his mother in Napa last August. He said he was dealing with the worst headache he ever had and the pain was increasing.

“That’s where it gets kind of blurry for me,” he said.

He was rushed to the hospital and told he only had 30 minutes to live. Doctors then told Ortiz that he needed to undergo emergency surgery as a tapeworm larvae was lodged in his brain.

The worm, which was wiggling when doctors pulled it out, had formed in a cyst that was blocking the flow of water to chambers in the brain, “like a cork in a bottle,” Dr. Soren Singel explained.

Humans can get tapeworms from eating uncooked pork, swimming in rivers or when traveling abroad. Doctors often see patients in California with the parasite after they have traveled to Mexico as well as other parts of Central and South America.

As we previously reported, a man in Colombia got cancer cells in his body from a tapeworm. He later died of kidney failure.

Experts say when traveling to a third-world country only consume safe food and unopened, bottled water.