Facebook has admitted a serious problem with the platform’s advertising function that is allowing racial discrimination on its site. But there is a way to fix it — if the company is willing.

In the spring of 2016, Facebook rolled out its “ethnic affinity” feature, which allowed advertisers to target Facebook users labeled as African American, Latino, or Asian American based upon their behavior on Facebook. Advertisers could opt to include or to exclude users in these categories. Facebook said that these labels were not equivalent to race because they were based not on users’ actual racial identities, but on whether they engaged with Facebook pages associated with those racial communities. Nonetheless, it identified the categories as “demographics” in its options for advertisers.

The system made it easy to exclude users marked as African American from seeing ads for anything, including job postings and credit or housing opportunities. Yet civil rights laws like the Fair Housing Act make this kind of discriminatory advertising illegal.

In October 2016, ProPublica was able to place a housing-related ad that targeted house hunters and those likely to move, excluding users marked as African American, Asian American, or Hispanic. The story prompted an immediate outcry. The Congressional Black Caucus contacted Facebook, and the Department of Housing and Urban Development, which enforces fair housing laws, said the revelations raised “serious concerns.”

Make no mistake, this is not simply an advertising problem — this is a civil rights problem made all the more dangerous by social media’s technological advances. Online personalization opens up significant possibilities for discrimination against marginalized communities, including people of color and other members of protected classes. In the offline world, we have thankfully moved past the era of housing advertisements that explicitly stated that people of certain races, religions, or ethnicities could not apply. But with behavioral targeting online, discrimination no longer requires that kind of explicit statement. Instead, a property manager can simply display ads for housing only to white people, or Christians, or those without disabilities.