It all started with an ad on Backpage.com, an online site of classified ads that authorities say is often used for prostitution.

A man answered the ad April 22 and went to a house in Philadelphia's Frankford section, where two girls, ages 16 and 17, were waiting with a 28-year-old man named Reginald Lewis and another male. According to court documents, the four held the man at gunpoint, robbing him of $100 and his car keys. Lewis told the girls to perform sex acts on the man and took video. Then they drove him a short distance and released him.

The girls have been charged as adults with the same offenses as Lewis, including kidnapping, simple assault, false imprisonment, theft, and conspiracy. But at a bail hearing, one girl's public defender, Beverly Beaver, noted that state law defines any commercial sex with a minor as human trafficking. She said the girl was a victim, forced first to prostitute herself and then to participate in the alleged crime.

Assistant District Attorney Elizabeth Fischer saw it differently. The girl, she said, "held the complainant at gunpoint for about an hour. This defendant knew what she was doing. … The fact is, human-trafficking victims don't hold people at gunpoint."

Are teens who get caught up in prostitution – and then are charged with related crimes – victims or perpetrators?

That question is at the crux of "safe harbor" legislation, passed unanimously out of the Pennsylvania Senate in April, that would make juveniles immune from prosecution for prostitution. It also would divert to the child-welfare system some charges that tend to go along with prostitution – critics call them "masking" charges, like false identification, disorderly conduct, loitering, criminal trespass. The proposed bill would offer no protection in cases involving more serious charges like the Frankford case; to advocates, that means it doesn't go far enough.

State Sen. Daylin Leach (D., Montgomery) has advocated such protections since 2013, introducing similar legislation in three consecutive sessions. He described the bill's current iteration as "watered down" but still vital.

If the House doesn't take up the bill this time, he said, he'll explore other avenues.

"I'm contemplating filing a lawsuit to stop the practice of charging underage children with prostitution. It is illegal in Pennsylvania for a juvenile to consent to sex with an adult. That's what statutory rape laws are," Leach said. "If these girls legally cannot give consent, how can they be charged with a crime for something they can't consent to?"

Leach has been involved in legal challenges before. He was a plaintiff in a lawsuit that successfully blocked a state law that would have allowed the National Rifle Association to sue municipalities over local gun-control laws, and was part of the litigation that defeated the state voter-ID law.

He sees protections for victims of sex trafficking as an urgent matter. But Tom Dymek, executive director of the House Judiciary Committee, said it was not at the top of the committee's list. "It's under consideration," he said. "We're in Month Six of a 24-month session."

One sign that the movement may have traction: The Pennsylvania District Attorneys Association – which opposed previous iterations of the bill that provided immunity to additional charges – won't object to this one, according to executive director Richard Long. "PDAA recognizes that a comprehensive approach is needed to effectively address the reprehensible sexual exploitation of children," he said in a statement.

In Philadelphia, minors who are believed to be victims of sexual exploitation and are charged in the juvenile system go to a specialized program, WRAP Court – it stands for Working to Restore Adolescents' Power – that can divert their cases into the child-welfare system.

Leola Hardy, a policy analyst at the Defender Association of Philadelphia who formerly staffed WRAP Court as a public defender, said that in Philadelphia, underage girls already are not charged with prostitution.

At WRAP Court, they often faced other charges, ranging from retail theft, theft of services, and false identification to assault, robbery, drug possession, or selling drugs. However, Hardy said, "almost everyone got diverted in some way. The goal was not to punish them but to get them help."

Advocates say the situation is improved from just a few years ago. It's only since 2014 that Pennsylvania has had a law defining the crime of sex trafficking. Historically, prostitutes were prosecuted far more often than johns. In Philadelphia in 2014 and 2015, there were 4,005 arrests for selling sex and 1,022 for buying sex.

Shea Rhodes, director of the Villanova Law Institute to Address Victims of Commercial Sexual Exploitation, said a paradigm shift has been underway.

"Law enforcement, in their regular encounters with individuals who have been prostituted, haven't known the signs and are really starting to engage in a fashion that is more victim-centered," Rhodes said. "That's important, because the victims themselves often don't identify as being victimized."

But to Hardy, the Frankford case shows protections even stronger than those under consideration in the legislature are needed.

"The new safe harbor laws enumerate certain charges in which you can invoke the human trafficking act, in which the district attorney is supposed to go first with diversion," Hardy said. "Most of them are very low-level offenses. But you find these victims in all sorts of compromising cases. It may be a robbery or it could be an assault. I really think it should be: Is this girl or boy a victim, a juvenile victim, of human trafficking? If so, what can we do to help them?"

The mother of one of the two girls charged in the Frankford case said they feared disobeying Lewis. The mother said she also had been living in fear after Lewis, armed with a gun, had invaded and taken charge of her home for more than a week, requiring the girls to have sex with him and to advertise on Backpage. Court documents do not disclose the content of the ad.

"What's going to happen to my daughter?" said the mother, wiping away tears. "We just feel like she shouldn't be in prison. These are things she was forced to do."

The girls' names are being withheld by the Inquirer and Daily News because they are seeking to have their cases moved to Juvenile Court. If that happens, they might have a chance to go to WRAP Court. Or they could stay in the adult system and face serious penalties.

"To me, they're sex-trafficking victims. You've got all the signs here," said Rhodes, a former Philadelphia assistant district attorney who helped to start a diversionary court for prostitutes. If the two girls were involved in the robbery, she said, "I think that the next questions to ask as these investigations continue are: What would the consequences have been if they hadn't done what he told them to?"

For trafficking victims, she said, "it's all about survival."