Facebook said on Friday it would stop advertisers from using its ethnicity-based ad-targeting feature on some ads, following criticism that advertisers could misuse the tool.

The feature, intended to help advertisers reach ethnic groups with relevant ads, has come under fire from politicians and civil rights leaders for allowing advertisers to exclude users from seeing ads based on their race.

Facebook will disable use of the tool, called “Ethnic Affinities,” for ads that offer housing, employment, and the extension of credit—areas where certain ethnicities have historically faced discrimination, the social network said in a blog post.

“There are many non-discriminatory uses of our ethnic affinity solution in these areas, but we have decided that we can best guard against discrimination by suspending these types of ads,” Erin Egan, Facebook’s chief privacy officer, wrote.

Get Data Sheet, Fortune’s technology newsletter.

Facebook’s advertising policy will now require a commitment from advertisers that they will not engage in discriminatory advertising on its platform, the company said.

ProPublica, a non-profit news organization, reported last month that Facebook lets advertisers exclude users by race, possibly violating federal housing and civil rights laws.

Facebook said it would also provide material to educate advertisers about advertising related to housing, employment, and credit.