America is exceptionally good at sending members of its military into harm’s way. We are far less good at managing what happens when those men and women come home.

I recently toured the Vista Detention Facility north of San Diego and saw this problem firsthand. Although the facility’s staff is doing commendable work, the fact that so many veterans are there in the first place shows how our efforts are falling short.

Frankly, it broke my heart.

Every year, roughly 200,000 service members leave our armed forces and begin the sometimes rocky transition to civilian life. Most succeed. They raise families, build businesses, become teachers and police officers, coach Little League and serve their communities in other ways. But some struggle, and more than a few end up in places like Vista, or worse.

When this happens, our first instinct is to ask: What did this veteran do wrong? We should be asking the harder question too: Are we doing enough to prevent those who served from becoming entangled in the criminal justice system?

The answer, unfortunately, is no.

The nonpartisan Council on Criminal Justice Veterans Justice Commission, which I direct, has documented a troubling connection between military separation practices, unmet needs and veterans’ subsequent involvement in the justice system. Tens of thousands of veterans are currently incarcerated, and roughly one-third of veterans report having been arrested and booked into jail at some point in their lives.

These statistics do not mean that military service causes criminal behavior. They do mean that we need to look harder — and earlier — at what happens to service members before they turn in their uniforms and become veterans.

One factor that merits concern is the dramatic growth of “bad paper,” shorthand for other-than-honorable discharges. The percentage of service members receiving such discharges has increased a whopping fivefold since World War II. But here’s the bigger news: While other-than-honorable discharges constitute approximately 6% of all discharges, they make up 18% of the discharges held by incarcerated veterans.

Commanders have a responsibility to maintain order and readiness among their troops. When a service member repeatedly misbehaves, abuses drugs or alcohol or fails to meet standards, commanders must act.

But they face a dilemma. The easiest way to remove a troubled service member from service is often a “bad paper” administrative discharge. The harder choice is to determine why the behavior is occurring, and whether targeted, evidence-based intervention might change it.

Is there combat-related PTSD? An undiagnosed brain injury? Military sexual trauma? Another treatable condition? Too often, in our haste to purge the troublemaker and get back to business, these possibilities are not even considered.

In short, although the military has become very good at identifying and managing risk on the battlefield, its leaders need to be equally committed to identifying risk in our own ranks.

Our failure to do so triggers life-altering consequences. Veterans with other-than-honorable discharges can face significant barriers to Veterans Affairs services, including the very treatment they need to address what caused them to misbehave in the first place. That gap in care can turn a difficult exit from the military into a downward spiral. Veterans are more likely to experience homelessness and a range of behavioral and mental health challenges. For some, an encounter with the criminal justice system comes next.

To short-circuit this cycle, the Pentagon should equip commanders with evidence-based tools to distinguish between a service member who simply refuses to meet standards and one whose misconduct may be linked to trauma experienced in the service.

Yes, sometimes separation will be necessary, but our society shouldn’t treat human beings as defective parts that should simply be axed from the inventory. That is effectively what today’s system forces commanders to do. By making administrative discharge the default because rehabilitation is difficult, the Pentagon is often transferring the problem from the military to individual veterans, their families and, ultimately, the community.

The Veterans Justice Commission has offered practical recommendations to help: better assessment of service members involved in military justice, evidence-based interventions when appropriate, greater use of rehabilitation and retention options, and reforms to ensure all veterans not discharged under dishonorable conditions have access to VA care

The Pentagon and the Department of Veterans Affairs should act on these proposals. This isn’t about being soft on misconduct; it’s about being smart. It’s about preventing early warning signs from morphing into criminal behavior, when effective intervention might have prevented it.

We recruited these men and women. We spent thousands of dollars to train them. In some cases, we made them vulnerable to harm and exposed them to things other Americans will never face — and would find unimaginable.

When their service ends, our responsibility for them does not. We must not abandon them when they struggle, and we must do whatever we can to ensure the veteran we thank on the street today does not become the offender we incarcerate tomorrow.

Let’s be better for those who volunteered to defend our freedom. It benefits all of us, and we have a moral obligation to do so.

Retired Brig. Gen. David “Mac” MacEwen is director of the Council on Criminal Justice Veterans Justice Commission.