Facebook said on Wednesday it was temporarily disabling the ability of advertisers on its social network to exclude racial groups from the intended audience of ads while it studies how the feature could be used to discriminate.
Facebook’s chief operating officer, Sheryl Sandberg, told African-American U.S. lawmakers in a letter that the company was determined to do better after a news report said Facebook had failed to block discriminatory ads.
The U.S.-based news organization ProPublica reported last week that, as part of an investigation, it had purchased discriminatory housing ads on Facebook and slipped them past the company’s review process, despite claims by Facebook months earlier that it was able to detect and block such ads.
“Until we can better ensure that our tools will not be used inappropriately, we are disabling the option that permits advertisers to exclude multicultural affinity segments from the audience for their ads,” Sandberg wrote in the letter to the Congressional Black Caucus, according to a copy posted online by ProPublica.
It is unlawful under U.S. law to publish certain types of ads if they indicate a preference based on race, religion, sex or certain classifications.
Facebook, the world’s largest social network with 2.1 billion users and $36 billion in annual revenue, has been on the defensive for its advertising practices.
Get Data Sheet, Fortune’s technology newsletter.
In September it disclosed the existence of Russia-linked ads that ran during the 2016 U.S. election campaign. The same month it turned off a tool, also reported by ProPublica, that had inadvertently let advertisers target based on people’s self-reported job, even if the job was “Jew hater.”
Sandberg said in the letter that advertisers who use Facebook’s targeting options to include certain races for ads about housing, employment or credit will have to certify to Facebook that they are complying with Facebook’s anti-discrimination policy and with applicable law.
Sandberg defended race- and culture-based marketing in general, saying it was a common and legitimate practice in the ad industry to try to reach specific communities.
U.S. Representative Robin Kelly, a member of the Congressional Black Caucus, said Facebook’s action was appropriate.
“When I first raised this issue with Facebook, I was disappointed,” Kelly, a Democrat, said in a statement. “When it became necessary to raise the issue again, I was irritated. Thankfully, we’ve been able to establish a constructive pipeline of communication that’s resulted in a positive step forward.”