Facebook announced Tuesday that it would make “legally binding” changes to its advertising platform, removing some features that allowed discrimination in housing, employment, insurance and credit ads.

The social networking company’s pledges came in response to an investigation by the state of Washington prompted by a November 2016 ProPublica article. The article disclosed that the company’s software made it possible for marketers to tailor who saw Facebook ads by race, gender, nationality and other characteristics protected by the Fair Housing Act of 1968.

The housing act bars publication of any advertisement “with respect to the sale or rental of a dwelling that indicates any preference, limitation, or discrimination based on race, color, religion, sex, handicap, familial status, or national origin.”

The Daily Digest Get the latest news from ProPublica every afternoon.

An initial test by ProPublica of Facebook’s automated ad system in 2016 revealed that discriminatory ads for housing sailed through in seconds. That story prompted the company to say that it would institute much stricter controls to prevent advertising that excluded particular groups.

In November 2017, we tested the system again, and found that Facebook had not made any meaningful changes. Third-party advertisers equipped with Facebook’s targeting tools were still able to block users the company identified as belonging to “multicultural affinity” categories like “Hispanic US” or “African American” from seeing ads on their newsfeed for housing, employment and credit opportunities. In some cases, we found specific instances of discrimination, including more than two dozen companies that had taken out job ads exclusively targeting younger job seekers.

Facebook’s advertising portal has since faced legal challenge on multiple fronts, including a lawsuit alleging housing discrimination and a lawsuit arguing against illegal age bias in employment ads. Investigators in Washington Attorney General Bob Ferguson’s office expanded upon the ProPublica inquiry by purchasing 20 more fake ads that cleared the approval process and hunting for live ads excluding protected categories of people from opportunities. The office said it found real-world examples of ads that did just that.

“Facebook’s advertising platform allowed unlawful discrimination on the basis of race, sexual orientation, disability and religion,” said Ferguson. “That’s wrong, illegal, and unfair.”

Facebook says changes will apply nationwide, and says many of the required changes have already been rolled out. In a statement late last year, the company promised to make temporary changes preventing advertisers from excluding audiences by race while it studied the use of its advertising system, claiming: “We believe advertising should be safe and civil. It should not divide or discriminate.”

In April, it announced more updates, including the removal of some exclusionary categories advertisers could use to target by ethnicity, disability, and more.

Help Hold Facebook Accountable Updated: Facebook Political Ad Collector See how political advertisers target you. Use this database to search for political ads based on who was meant to see them.

The settlement with Washington requires more permanent fixes, and added legal pressure requiring the company to follow through within the next 90 days. The agreement says Facebook can no longer display drop-down menus allowing advertisers to exclude ethnic groups from advertisements for housing, credit, employment, insurance or “public accommodations” of any kind, ranging from “auto dealers, beauty salons and restaurants to colleges, hospitals and professional sports stadiums.” The social network service also must pay the attorney general’s office $90,000 in costs and fees.

In the settlement, however, Facebook denies that its platform violated anti-discrimination law, citing immunity under Section 230 of the Communications Decency Act of 1996, which bars claim against internet companies for content it hosts. The agreement also stipulates that the company will not be held liable for more subtle categories related to protected characteristics — only those that “on their face directly describe a Facebook user as possessing a “Protected Characteristic.” An advertiser can no longer exclude “wheelchair users” or “Chinese people,” for example, but will be able to exclude those interested in “disability rights” or “Chinese literature.” Advertisers can also continue to use Facebook’s tools to target by age and gender.

“I think it’s a really good first step to bind Facebook to many of the prior commitments that Facebook made publicly. There is a real difference between a legal agreement that can be enforceable in court versus a company’s promises it can break without any real consequence,” said Peter Romer-Friedman, a lawyer with Outten & Golden LLP and the lead attorney on two anti-discrimination lawsuits filed against Facebook. “At the same time, this agreement commits Facebook to not much more than what it already previously committed to doing.”

The state of Washington is posing a legal challenge to Facebook in at least one more case this year. Attorney General Ferguson has also sued both Facebook and Google for a decade’s worth of “negligent and/or intentional violations of state law on political ad transparency. That case is likely to unfold in federal court.