(Reuters) — The U.S. Department of Housing and Urban Development (HUD) charged Facebook on Thursday with violating the Fair Housing Act, alleging that the company’s targeted advertising discriminated on the basis of race and color.

HUD said Facebook also restricted who could see housing-related ads based on national origin, religion, familial status, sex and disability.

Facebook said it was surprised by the decision and has been working with HUD to address its concerns and has taken significant steps to prevent ads discrimination across its platforms.

The social media giant said last week it would create a new advertising portal for ads linked to housing and employment that would limit targeting options for advertisers.

“Facebook is discriminating against people based upon who they are and where they live,” HUD Secretary Ben Carson said. “Using a computer to limit a person’s housing choices can be just as discriminatory as slamming a door in someone’s face.”

The Fair Housing Act prohibits discrimination in housing and related services, which includes online advertisements, based on race, color, national origin, religion, sex, disability, or familial status.

(Reporting by Akanksha Rana in Bengaluru; Editing by Saumyadeb Chakrabarty)