When a Texas woman was raped by a doctor while under sedation at Ben Taub General Hospital in Houston, it took her nearly five years, one failed civil case, and a two-week criminal trial to get any semblance of justice. In August, a jury found Shafeeq Sheikh, who was a third-year resident at the time of the attack, guilty of sexual assault and sentenced him to ten years of probation.

A month later, Justin Schneider, an air traffic controller from Alaska, took a plea deal after he was indicted for allegedly kidnapping an Alaska Native woman, choking her to the point of unconsciousness, and masturbating on her. Schneider pleaded guilty to one count of felony assault and was sentenced to time served, plus three years probation. Because unwanted contact with semen isn’t considered a sex crime under Alaska state law, Schneider doesn’t have to register as a sex offender.

Then there’s one of the most infamous cases: Brock Turner, the Stanford-swimmer-turned-convicted-rapist who was released in 2016 after just three months in county jail.

These stories prompt public outrage—but they’re all too common.

Get the facts, direct to your inbox.

National statistics on sentencing in sexual assault cases are limited, but a 2006 survey by the Bureau of Justice Statistics found that nearly 20 percent of convicted violent sexual offenders are never sentenced to incarceration. For comparison, only 15 percent of people convicted of robbery and 5 percent of people convicted of murder or nonnegligent manslaughter avoid serving time behind bars.

According to analysis of the 2010-2014 National Crime Victimization Survey by the Rape, Abuse, and Incest National Network (RAINN), once you take into account the number of sexual assaults that go unreported and reported cases that never lead to arrest or prosecution, only six out of every 1000 perpetrators will be incarcerated.

Sexual assault cases are notoriously difficult to try and plagued by subjectivity. When it comes to sentencing, judges or jurors are supposed to consider their state’s sentencing guidelines, the severity of the crime, the offender’s prior record and other factors. But it’s an imperfect science that often favors well-to-do white men.

“There has to be accountability on the part of the offender for committing a very serious crime like sexual assault, but that has to be balanced with some discretion on the part of the judge to mitigate sentences in cases where it seems justified,” said Cassia Spohn, the director of Arizona State University’s School of Criminology and Criminal Justice. “The problem, of course, is that where it seems justified is a very subjective kind of assessment.”

Past criminal history is generally the best predictor of whether an offender will be incarcerated. Spohn said, “Judges are willing to give the benefit of the doubt to offenders who have a relatively unblemished record, even if even if the charges are quite serious.”

While leniency for first-time offenders—especially those with circumstances that could further mitigate punishment, like family obligations (Sheikh and Schneider are both married with children) or educational prospects—is an important aspect of judicial discretion, it is also inextricably linked to race and gender. For one, men of color are more likely to have prior records—which can be attributed, in part, to racial bias at all junctures of the criminal justice system.

Decades of studies have also found that men of color, particularly Black and Latino men, are sentenced more harshly than white men in similar circumstances. Across several different offenses, Spohn and others have found that while race may not influence the length of sentences, it has “a direct effect” on the type of sentences (prison versus probation) given.

According to researchers at the University of Maryland, the only exceptions are Asian American offenders, whose punishments are comparable to their white counterparts.

What makes sexual assault cases unique is that the race of the victim can also play a role in sentencing. Studies of the “sexual stratification hypothesis” have found that Black offenders who sexually assault white victims face the harshest punishments. Conversely, sexual assaults committed against victims of color (especially Black women) see the most leniency.

Jennifer Long, the co-founder and CEO of AEquitas: The Prosecutors’ Resource on Violence Against Women, worries that light sentences may come across as minimizing the seriousness of violence against women.

“There are some people who work in this field that say, ‘You know, with treatment the risk of reoffense is low,‘ and I sometimes bristle at that because we’re talking about the reoffense of a sex offense and victims who are vulnerable,” Long said. “So my risk tolerance for something like that—not that I would brush any crime aside—I just feel like that’s a really cavalier way of talking about someone who can commit a lot of harm.”

Take Sheikh, for instance. He has joined ranks with 17.6 percent of convicted sexual offenders in Texas who did not immediately serve time in prisons or state jail for the crime, despite the prosecution’s request that he get the maximum sentence.

“As a doctor, to come in and test the waters a little bit, checking her multiple times before ultimately assaulting her, to me, that’s calculated—hunting someone to prey on,” said Harris County Assistant District Attorney Lauren Reeder. “The facts of that justify a full 20-year sentence.”

Instead, Sheikh is serving ten years’ probation and registering as a sex offender. The county waived his $10,000 fine. He could potentially keep his medical license, thanks to a loophole in Texas law, because he was never imprisoned.

So what constitutes justice in cases like these? Lawyers and other experts agree that it varies from case to case. Janna Oswald, a prosecutor in Houston, told Rewire.News that some victims push for the maximum prison sentences, whereas others simply want the perpetrator to acknowledge wrongdoing. Many just want their lives to return to normal.

Randolph Rice, a Baltimore defense attorney, countered that considering mitigating circumstances is vital to fair sentencing. Many of his clients who are charged with sexual assault, he told Rewire.News, have underlying mental health issues, so he sends them to counseling before trial ever starts. He wants a judge or jury to understand “how [a defendant] got to this point” and what they’re doing to improve themselves.

Long says the road to justice is paved with small changes, like police believing victims who report assault and judges articulating sentences in a way that doesn’t blame victims. Studies from multiple state court systems have found that the best way to eliminate racial and gender bias is through proactive measures to increase diversity throughout the criminal justice system. Many also recommend instituting ongoing task forces to oversee diversity and other anti-bias efforts.

“I think all of those things influence whether people want to engage with the criminal justice system,” Long said. “It’s really why we exist. We want to make the criminal justice system a place where victims want to come forward because it does afford fairness to the defense and defendants, but it also affords an opportunity to have victims have a voice.”