SACRAMENTO, Calif. (AP) — Police in California would no longer be able to arrest anyone for loitering with the intent to engage in prostitution under a bill advanced by state lawmakers on Friday amid debate over whether the move would help or harm sex trafficking victims.

Sen. Scott Wiener, a Democrat from San Francisco, argues that the crime too often depends on an officer’s perception and results in disproportionate arrests of transgender, Black and Latino women.

READ MORE: Memorial Service For Fallen Marine Sgt. Nicole Gee Held In Roseville

His bill would repeal that portion of California law. It was approved in the Assembly on a 41-26 vote. It returns to the Senate for final consideration before lawmakers adjourn for the year on Friday.

It would also allow those who are currently serving sentences or who were previously convicted to ask a court to dismiss and seal the record of the conviction.

Similar legislation became law in New York in February. Wiener said the measures are part of an effort to end discrimination against and violence toward sex workers.

The current law harms public safety and trafficking victims by increasing the mistrust of police particularly among targeted communities, which “means people will not engage with law enforcement when they need it,” said Democratic Assemblywoman Rebecca Bauer-Kahan during the Assembly debate.

“Criminalizing the victims and leaving them with criminal records that create further barriers to seeking employment, housing and relief is not the answer,” she said.

Opponents rallied at the state Capitol on Tuesday, arguing that the measure essentially legalizes the most dangerous form of prostitution. The measure endangers those who are forced into sex trafficking, they argued.

It would “severely undermine the ability of law enforcement to investigate trafficking crimes,” numerous opponents said in a letter to lawmakers last month. The bill assumes that sex work is voluntary, when the opponents contend that many are coerced.

Supporters of the bill “made it seem like this group simply gets judged and targeted because they are minding their own business and standing on corners, and that’s just simply not the case,” sex-trafficking survivor Sable Horton said in a statement.

READ MORE: Suspect Armed With An Ax Arrested In Stockton

Bauer-Kahan took offense when Assemblyman Jim Cooper, a fellow Democrat and former Sacramento County sheriff’s captain, said officers should be allowed to presume that women who are provocatively “dressed like that” and carrying “a purse full of condoms” are street walkers.

“It’s not rocket science,” Cooper said. “You know who the players are and who they aren’t.”

“I know I’m probably not the only woman on the floor that was triggered when one of our colleagues said, ‘Well, they’re dressed that way,’” responded Bauer-Kahan. “Being ‘dressed that way’ is not a crime, and it will never be OK to be victimized because you were dressed in any manner.”

The bill had support from both a former public defender, Assemblyman Ash Kalra, and a former prosecutor, Assemblyman Al Muratsuchi, both Democrats.

“Law enforcement can help people without threatening to arrest them,” Kalra said.

“This simply eliminates this vague provision in the penal code that allows for abuses for people that they simply be profiled for the wrong reasons,” Muratsuchi said.

Wiener’s bill has support from the American Civil Liberties Union as well as groups representing LGTBQ individuals and sex workers.

The ACLU said the measure “eliminates a law that allows police to rely on bias rather than evidence to criminalize otherwise legal activities like walking, dressing or standing in public.”

Also Friday, the Assembly approved and returned to the Senate for final action a bill responding to the 2019 mass shooting at a synagogue in Poway, California. The underage gunman was able to buy his assault weapon because his lack of a valid hunting license wasn’t verified, a loophole the bill aims to close.

MORE NEWS: Antelope Woman's Stolen Cotton Candy Trailer Located In Rio Linda

The same bill would broaden a new mandate that the state attorney general investigate all fatal shootings by police of unarmed civilians to include instances where there is a reasonable dispute whether that civilian was armed.