Over five million Americans, more than the population of Costa Rica, Ireland, or New Zealand, hold a security clearance. These clearances are issued by the United States government (via the Department of Defense, CIA, the State Department, etc.) and establish that as a result of an investigation the holder can be trusted to handle sensitive documents and duties.

Of all those who are cleared, some three dozen White House staffers, including the recently resigned Rob Porter, have only “interim” security clearances. So how does an interim clearance differ from a full one? How do you get cleared? And how did accused spouse abuser Porter stay on the job even after his past came to light?

“Getting cleared” involves two broad steps: investigation and adjudication. Cases like Rob Porter’s expose the gap between the two, and the danger of using interim clearances as more than a temporary expedient for an oftentimes slow process.

Most everyone seeking a clearance begins at the same place: Standard Form 86, Questionnaire for National Security Positions. The SF-86 provides a very detailed autobiography, raw material that fuels the rest of the process. Young people filling out their first SF-86 invariably end up on the phone to mom, gathering old addresses, birthdays of disconnected relatives, foreign countries visited on family trips—and more, a lot more: the SF-86 runs some 133 pages. After the names and dates, the SF-86 dips into tough questions about financial problems, drugs, gambling, drinking, and mental health.

Every applicant then gets run through a variety of databases. The goal is to verify quickly as much of the SF-86 as possible while at the same time skimming off the low-hanging fruit of obviously unqualified people. Checks are also run through various intelligence files (the “National Agency Check”). All that typically screens out 20-30 percent of candidates. It is likely it would have been at this point that Rob Porter’s spousal abuse allegations would have come to light, as they were listed in easily accessible public records. Yet he wasn’t screened out.

For some low-level clearances, the process can conclude there with a decision. For higher-level clearances that take additional time to complete, like Porter’s, an interim clearance up to the Top Secret level can be granted if the person needs to start work. There is no government-wide rule regarding interim clearances; they’re issued on a case-by-case basis.

To secure a full high-level clearance, next is a field investigation. Investigators (in the case of the White House, the FBI; agencies like State and CIA have their own teams) will visit an applicant’s old teachers, his neighbors, parents, and almost certainly the local police force to ask questions. This is old-fashioned detective work: knocking on doors and eyeballing people who know the applicant. If an applicant lived abroad, the process is tasked out through the appropriate U.S. embassy. Field investigations typically take at least a year, and much longer for those with significant foreign contacts.

Finally, for many positions, including those at the CIA and NSA but usually not those at the White House, is the polygraph, the lie detector. The federal government polys about 70,000 people a year in connection with security clearances. In some instances, only a limited polygraph will be conducted, as opposed to a full lifestyle test. In a “coordination of expectations” review, used in many military and update situations, only limited questions are asked. Sometimes the subject will even know them in advance, such as “Have you transferred classified information without authorization?”

No matter the technique, the point is the same: identify vulnerabilities to recruitment. Unlike in the high-tech spy world of the movies, most really useful information is obtained from people who hand it over to a foreign intelligence officer in return for something. The most common vulnerability is money, which is why those with significant debt, bad credit, or gambling problems make for security risks. “Foreign preference” plays a big role, too, especially for so-called hyphenated Americans (Greek-Americans, Chinese-Americans, etc.) who can be made to believe they are simply helping “the old country,” not hurting the U.S. Blackmail plays a role in fewer cases than commonly held, which makes sense. Those coerced into cooperating want nothing more than to escape their predicament, whereas those paid to cooperate will likely be inclined to cooperate further, for more money.

Few people are perfect, few are really bad. Many hold great affection for their parents’ native lands, but will it drive them to treason? They might have debt, or drink, or cheat on their spouses, but is it “too much”? Someone has to make a decision. That decision—an adjudication—relies on human judgment applying agreed-upon standards.

Adjudication standards evolve with society. Once, any illegal drug use was a near-automatic rejection. Now most agencies use “The Obama Rule,” where limited youthful experimentation is generously taken in context. The watchword is mitigation, good things in someone’s record (such as the passage of time) that lessen the impact of bad ones. As student debt has risen, how much money a 22-year-old owes is seen differently today than it was in an era when more parents were able to pay for their kids’ education. One of the biggest changes has to do with LGBTQ applicants: gay men were once automatically labeled blackmail targets and now no longer are. The basics are online. Drugs? Right here.

Yet for all the apparent clarity, the adjudication process often becomes entangled with the question of suitability (also called fitness), which is where the Rob Porter case crashed and burned. Just because someone is not vulnerable to recruitment doesn’t mean they are suitable. For example, a candidate who smoked a little weed in college isn’t likely to be turned by the Russians, but still might be unsuitable for an administration taking a hard line on drugs. In the same way, the process can be twisted so someone with a history of spousal abuse might still be seen as suitable to work beside the president.

Particularly in the intelligence community, the agency itself investigates and adjudicates. In the case of the White House, however, the FBI does not determine whether someone receives a clearance; it only conducts the investigation. The adjudication is made by officials in the Executive Office of the President. Politics plays a role.

In Porter’s case, adjudicating officials (suspicion focuses on chief of staff John Kelly) were aware of the spousal abuse allegations, yet concluded he was not vulnerable enough to blackmail to prevent an interim clearance. Those same officials then applied a suitability standard—wholly at odds with what the majority of society thinks—to determine whether Porter, despite his history, was fit to work in the White House. Someone misapplied a process that was supposed to resolve Porter’s fitness to see classified material to also determine his broader responsibility for previous behavior.

Those same officials understood that Porter’s case would never pass the published standards for a full clearance, and hid their decision behind what appears to have been intended to be a forever interim clearance (the White House has since announced it will not issue interim clearances in most cases going forward).

This is not a system breakdown. It is a failure of one or more individuals to uphold the standards of the system. That is a topic very much worthy of congressional investigation.

Peter Van Buren, a 24-year State Department veteran, is the author of We Meant Well: How I Helped Lose the Battle for the Hearts and Minds of the Iraqi People and Hooper’s War: A Novel of WWII Japan. He Tweets @WeMeantWell.