If the fire-engine red of the lobster on your plate makes you painfully aware that it was boiled alive, think of it this way: The bright color is simply the result of a chemical reaction.

Lobsters’ usual greenish-blue hue serves them well in life, camouflaging them from the predatory eyes of cod, haddock, and other large fish that prowl the ocean floor. Anita Kim, a scientist at the New England Aquarium, explained to Live Science that this color results from the combination of two molecules.

One is astaxanthin, a bright red carotenoid that lobsters absorb by eating things that contain it. The other is crustacyanin, a protein that already exists in lobsters. When crustacyanin binds with astaxanthin, it twists the molecule into a different shape, which changes how it reflects light. So instead of red, live lobsters are blue.

Then, when you boil one of the tasty crustaceans, the heat causes the crustacyanin molecules to contort into new shapes. In doing so, they release the astaxanthin molecules, which rebound to their original shape and red color. Michele Cianci, a biochemist at Italy’s Marche Polytechnic University where the phenomenon was investigated, likened it to manipulating a rubber band with your hands. “You can impose any kind of configuration you want,” he told Live Science. “When you release the rubber band, it goes back to its own shape.”

The same thing happens with shrimp, which go from ghostly gray to pink when you cook them. How, then, do flamingos turn pink from eating raw, almost colorless shrimp? Crustacyanin releases its hold on astaxanthin during the flamingos’ digestion process just like it does when heated.

By the way, don’t feel guilty about having torn your lobster away from its one true love—they don’t really mate for life.

[h/t Live Science]