Adapted with permission from Unfair: The New Science of Criminal Justice, by Adam Benforado. Crown Publishers, a division of Penguin Random House, LLC, June 16, 2015. Copyright © 2015, Adam Benforado. All rights reserved.

The water in the vat was untroubled and deep.

It had been prepared earlier for the brothers, Clement and Evrard. But they were still in the church, standing in front of the assembly, waiting like stalks for a breeze.

It was the winter of the year 1114. The days were getting shorter; the rain was coming to northern France. Clement and Evrard, who were peasants, lived in the small village of Bucy, a few miles east of Soissons.

The charge was heresy. The brothers had been betrayed by their neighbors: a woman Clement had purportedly been brainwashing for months, driving her mad, and a deacon who had heard Clement make statements against the Church.

But these accusers now failed to appear. And when questioned, the men “gave most Christian answers” and denied the charges against them, which presented a problem endemic to all systems of justice: a strong suspicion of guilt without solid evidence.

In twelfth-century France, however, there was a ready solution.

Following the celebration of Mass, the lord bishop and the archdeacon led Clement and Evrard to the vat. As they appeared before the water, the lord bishop spoke out the litany and delivered the exorcism. Tears rolled down his face. And Clement and Evrard, seemingly moved, gave an oath that they were not heretics and had never followed, nor taught, gospel contrary to the faith.

It was at this moment that Clement was thrown into the water.

This was not some ritual cleansing. This was the critical moment in the adjudicatory proceedings and the most important moment in Clement’s life. This was the trial—“the ordeal of exorcised water”—and it all came down to buoyancy.

As the ninth-century theologian Hincmar of Rheims explained, the man who “seeks to hide the truth by a lie, cannot be submerged in the waters above which the voice of the Lord God has thundered.” Baptismal water was pure and would naturally reject the bodies of those who were infected by falsehood. Murders, adulterers, and heretics would float; innocents would be enveloped.

An accused person like Clement would generally have been stripped of his clothes and bound with cords before being pushed into the pool. In some versions of the trial, the accused needed to sink to a certain distance—to the length of the hair on his head, for example—with a knot tied in the rope to assist with measuring.

In Clement’s case, though, no knot was needed. All could see. He “floated like a stick.”

To the men, women, and children who gathered at Soissons, this ordeal was no travesty: this was true, fair justice. Here were the most esteemed and respected members of society—cornerstones of the religious hierarchy—presiding over the ordeal as part of the official sacred Mass. And here was a neutral process that seemed to avoid the biases that came from other potential means of deciding cases. Witnesses could lie and judges could bow to political pressures, but God’s judgment was true and incorruptible. In an era in which the divine permeated every aspect of life, the various hot and cold ordeals—fishing a ring out of a boiling cauldron, carrying an iron straight from the fire, or being plunged into a vat of water—would have seemed quite rational and quite fair.

Today, with nine hundred years of perspective, it is easy to spot the flaws in the system. In ordeals of fire and water, the mechanism of deciding guilt was not grounded in fact. Innocent men and women could of course be burned by hot irons and boiling water. And what determined whether someone sank in a vat was largely a matter of the amount of air in the lungs and, more fundamentally, the percentage of body fat. Women and heavyset men were naturally—and unfairly—at a disadvantage.

Even if the process had been valid, the ordeals were not administered with any type of true consistency. When were the suspect’s answers under questioning good enough that the trial could be avoided altogether? How long did the iron have to sit in the coals? How bad did the hand have to look when it was unwrapped to be deemed clear evidence of guilt?

And for those of us living in Western democracies today, the idea of religious leaders overseeing criminal proceedings seems fundamentally misguided—as does punishing the crime of heresy at all. What interest does society have in prosecuting those who decry the baptism of children “not yet of an age of understanding”?

Most glaringly, how strange to think you can look inside a man’s head and discover his blasphemous thoughts by tossing him into a pool of water! It verges on comedy. In a scene from Monty Python and the Holy Grail, a village mob drags a purported witch before Sir Bedevere the Wise, who explains the process of adjudication as follows: both witches and wood burn, both wood and ducks float; therefore, if the woman weighs the same as a duck, she is most definitely a witch. The joyous crowd rushes off to the nearest set of scales. We laugh because this is so plainly absurd. It is shockingly unjust. It is shockingly irrational.

But how will someone nine hundred years from now view our current system of justice?

The truth is that our descendants will be no less surprised by the routine and systematic unfairness we tolerate today than we are by our ancestors’ trials by ordeal. They will look back at our judges and juries and see biases that are just as obvious as the ones we now perceive in the bishops and abbots who presided centuries ago. They will look back at our criminal code and see laws as wrongheaded and illegitimate as the prohibition on heresy. They will examine our processes and procedures—how strictly we followed them, how heartily we trumpeted them as bastions of integrity and accuracy—and laugh at our naïveté just as we laugh today at the mumbo-jumbo justice of Sir Bedevere the Wise. If there is a Monty Python of the thirtieth century, its members will write skits that look an awful lot like episodes of Law & Order.

We feel confident that we know our judicial system. We know why people commit crimes, how to identify the guilty, and what makes a good judge. And we know where we still have work to do. We acknowledge the rough edges, the lingering imperfections—the lying cops, racist jurors, lazy investigators, corrupt judges, biased witnesses, and self-aggrandizing lawyers—that threaten to unbalance our scales of justice.

Our intuitions are so ingrained that it’s hard to imagine they might be wrong. But in fact the forces we believe decide cases and determine outcomes form, at best, a badly incomplete list of concerns. At worst, they are largely irrelevant. Even if we quashed all the familiar problems that can derail a case, even if our system operated exactly as it was designed to, we would still end up with wrongful convictions, biased proceedings, trampled rights, and unequal treatment. Injustice is built into our legal structures and influences outcomes every minute of every day. And its origins lie not inside the dark heart of a bigoted police officer or a scheming D.A. but within the mind of each and every one of us.

Researchers in psychology and neuroscience have begun to expose these hidden dynamics undermining our criminal justice system. What their insights reveal is surprising and counterintuitive, even deeply unsettling: at the exact moments when we believe we are guided by reason and willpower, we are frequently propelled by automatic processes. Even as we feel that we are bending the environment to our ends, it is often the other way around, with seemingly insignificant elements in the world around us powerfully shaping our behavior.

Take our ability to accurately assess risk, which is at the heart of our legal system. We think we understand the factors that determine whether a cop draws his gun, where police departments and prosecutors allocate precious resources, how high a judge sets bail, and if legislators pass a tough new crime bill. We assume that the likelihood of an event and the seriousness of the consequences drive our appraisals, and that people with the same information will make the same risk calculations.

But a growing body of scientific evidence suggests that we are not the consistent, rational number crunchers that we suppose. If we have strongly negative feelings about something—like an assault by a pedophile—we will treat it as a significant risk regardless of how likely it is to occur. A one-in-five-million chance and a one-in-five-thousand chance look exactly the same to us. And it’s not just that we ignore probabilities; we can be in­sensitive to raw numbers as well. Indeed, sometimes when more people are in peril, we may actually care less. Mother Teresa was right: “If I look at the mass I will never act. If I look at the one, I will.” Research suggests that you’re significantly more likely to convince a lawmaker to support a new bill that will indefinitely detain certain sex offenders after they complete their sentences if you tell him about a specific child victim than if you explain that it will save a thousand statistical lives. It’s no coincidence that major pieces of legislation—like Megan’s Law and the Adam Walsh Act—have been motivated by the murder of a single child.

The news media further distorts our perceptions because our threat-detection system tends to rely heavily on whatever is within easy reach. Incidents that are prominent in our memories end up taking on an outsize role. And how easily we can recall an event influences not only our sense of how frequently that event occurs but also our sense of how important it is. It makes a difference, then, that there is far more coverage of serial rapists and child kidnappings than of diabetes deaths. Likewise, the disproportionate number of stories on the local news about crimes committed by young African American men increases people’s fear of black men and leads to an overvaluation of the threat they pose, which may in turn affect how police officers, prosecutors, judges, and jurors treat them.

I was drawn to these issues in the early days of law school, as I began to realize that the way we understand the thinking and behavior of our legal actors is incorrect—and, frequently, harmful. The more I read and thought about things, the more convinced I became that we need a new model, grounded in the science of the mind, for our legal system to be truly just. In the last decade I’ve dedicated my professional life to exposing the flaws and pointing the way forward.

Our judicial system is flexible enough to respond to new developments in the mind sciences that reveal flaws in our laws and processes. There are solutions and remedies within our reach. Some of these solutions, like reconceptualizing which behaviors we punish, are grand and ambitious and must be the focus of long-term efforts. But many others, directed at police training, rules of procedure, courtroom design, and our legal code, can be implemented in the near future. Whether we choose to pursue them will have less to do with our natural limitations and much more to do with the robustness of our commitment to equal justice under the law.