Believe it or not, tattooing has been around for thousands of years. In fact, researchers have found mummies and icemen that date as far back as 5,200 years who have tattoos on their remains. Though some people, like the Romans, shunned the idea of tattoos, several other groups—from the gangster yakuzagroups in Japan to the natives of Borneo and Tahiti—have a long history of embracing a tattoos for cultural or religious purposes.

Ancient tattoos were simple—and painful—utilizing the “stick and poke” method. In other words, a needle with ink on it punctured the skin repeatedly to create a permanent design. Luckily, modern ink aficionados don’t need to suffer nearly as much. You can thank Samuel F. O’Reilly for that. He submitted a patent for the modern tattoo machine in 1891, which was—fun fact—a modification of an earlier patent submitted by Thomas Edison. And we’re still making improvements to the machine today (the most recent patent was submitted in 2008) to make tattooing safer and less painful.

This video from TED-Ed goes into more detail on the history of tattoos if you really want to geek out:

How Tattooing Works

A needle in our modern tattoo machine can puncture the skin up to 3,000 times per minute. Depending on the artist, they may work with a single needle, a small bundle of needles, or a wide “brush” of needles (up to 32) for shading large areas. It all depends on the artist’s choice and the look of your design.

Of course, the big difference between a tattoo and those ballpoint-pen stars you doodled on your hand in high school is that tattoos are permanent. You might recall from science class that you have several layers of skin (or maybe not, if you were busy doodling stars). Your epidermis is the uppermost part and continuously regenerates skin cells. Below that is the dermis, which contains nerve endings, oil glands, and sweat glands—that’s where the needle embeds the ink.

After your skin initially heals from the injury caused by the needle, “your body starts to break down as much [of the ink] as it can,” says Tina Alster, M.D., director of the Washington Institute of Dermatologic Laser Surgery. “The body will try to get rid of anything that it doesn’t want there.” Solution? Send in the troops—i.e., your immune system.

The first line of defense are macrophages, a special type of white blood cell (the same kind that attack cancer cells) that will try to eat the ink molecules. Some macrophages will succeed and carry ink off to your nearest lymph node. Other ink molecules get engulfed by fibroblasts, the cells responsible for producing collagen, says Nazanin Saedi, M.D., director of laser surgery at Jefferson Dermatology Associates. More fighter cells will rush to the area, but in the end, your immune system can’t get rid of all the ink—and thus, your tattoo is permanent.

See it in action by watching this other TED-Ed video below:

Are Tattoos Dangerous?

So if that ink doesn’t ever leave your body, how do you know that it’s safe?

Currently there is no regulation of tattoo inks. Some artists use water to dilute concentrated tattoo pigments, and there’s not a ton of oversight there either (think tap water versus a sterile saline solution). While some inks use charred bone or glycerin derived from animal fat, the market for vegan inks has become increasingly popular over the last several years. Brands like Eternal Ink and Fusion Ink have material safety data sheets (MSDS) directly on their sites, so you know what goes into their products. Likewise, more and more studios are being transparent about the inks they use.

If you have concerns, ask about the types of ink being used, check the regulations in your state and make sure your studio is compliant.