Scientists at the City University of New York have found a way to recreate melanin’s pigment-changing properties in a synthetic polymer, according to a new study in Science. Melanin is the pigment that gives our skin, eyes, and hair their colors, causing variations like freckles and skin tans.

In the study, the CUNY researchers demonstrate that they can “tune” the properties of their melanin-like polymer with a great degree of control. They created pigments that varied in color from pale beige to dark brown.

Melanin is difficult for scientists to alter and manipulate because it has a disordered molecular structure, where there is no link between structure and function. These researchers used amino acid sequences to control the properties of the synthetic melanin polymers, creating a way to produce different colors of synthetic melanin pigments. The six different amino acid sequences they created led to six different pigment colors.

While the research is still ongoing, it has potential uses in medicine and cosmetics. Melanin protects against damage from UV rays and has antioxidant properties, which scientists think might be why people with darker skin have lower rates of skin cancer, so it could potentially be used to protect against sun exposure and skin damage. Melanin also has electric features—it’s an organic semiconductor—that make it a good candidate for biomedical devices.