He fit all the hallmarks of a disengaged high school student. The son of factory workers who never made it past middle school, the student got C-minus/D-plus grades and couldn’t wait to get out of high school. Yet a few years later, he graduated from community college with an associate degree and a 3.3 grade-point average. What changed?

“In college I was invested, I was paying,” the former student said. “Once it entails a cost, it’s not easy to just say, ‘Oh, let’s not go to class today.’ You’re just hurting yourself.”

Policymakers probably have low-income, first-generation college students like this one in mind when they propose making community colleges free. President Obama and both of the leading Democratic presidential candidates, Hillary Clinton and Bernie Sanders, have made free community college part of their repertoire. (And Sanders goes further, calling for all public universities and colleges to be tuition-free.) The problem is, “free” might come at a cost.

Leading a Northwestern University research team with my colleague James Rosenbaum (with funding through a grant from the Spencer Foundation), I spent a year interviewing 80 people who completed two-year college degrees a decade ago. Many of these graduates had been low-performing students who prioritized partying and exerted little effort in high school. They consistently, sometimes fervently, told us that paying for college made them grow up and work hard. Paying tuition — even a relatively small or nominal amount — seemed to help unlock a new identity as a responsible student.

Europeanstudies have found that students who pay more in tuition exert greater effort and are more likely to graduate on time. Martin Coleman of North Dakota State University studied “sunk cost,” the phenomenon that people are more likely to continue with an endeavor in which they have made an investment. He found that people were more likely to stay in classes if they had already paid something in tuition — but that sunk cost did not apply if an endeavor was free and participants had invested only their time.

This is not to say we should favor tuition hikes. Two-year colleges are the engines of social mobility in the modern world, and cost is a barrier to many. Eighty percent of aid-eligible community college students face financial shortfalls even after aid is awarded.

However, free tuition will not solve today’s real problem: the gap between enrollment and graduation. Nearly 90 percent of high school graduates enroll in college within eight years, but graduation rates are another story, hovering around 39 percent for community colleges. Michal Kurlaender of the University of California at Davis finds that while free community college in the state may have led to higher enrollment, it has not translated into higher levels of persistence or graduation. Richard Reeves of the Brookings Institution concluded the same thing about free community colleges in Michigan and also noted that free tuition does little to close graduation gaps by race and income. The issue of underpreparedness is certainly a factor, but graduates also offer a partial explanation — as the cost of attending college drops to zero, so does the perceived cost of dropping out.

We must make college accessible to all without requiring hope-crushing loans, but we should use all the motivating factors we can. There are a few ideas to consider.

First, non-tuition expenses (books, transportation, child care, housing) often surpass the cost of tuition and the value of the average Pell Grant. What if, instead of making tuition free, we covered such expenses for students? It is easier to walk away from a free college that gets too difficult than a college you have paid tuition for that also gives you free housing. While the jury is still out on this approach, some colleges have creatively reduced non-tuition costs through methods such as transportation deals and free day care. The College of Saint Mary in Omaha, for example, has a dorm for single mothers and their children, reducing both living and child-care expenses. To their credit, both Sanders and Clinton would allow aid to be used toward non-tuition expenses.

Second, while investing in career services does not make college cheaper, it does help alleviate the burden of loans after graduation. Ten years out of college, graduates who had loans but also good jobs were doing fine; it was those who had loans and no fruitful career from their degrees who suffered. Our research has shown that investing in high-quality career services centers can positively affect graduates’ long-term earnings. This is particularly relevant to community colleges, where graduates often fail to get good jobs not because they lack skills but because they don’t know how to translate their degrees into jobs — they lack networks and job-search knowledge. Explicit help navigating from college to work helps graduates get good jobs that allow them to pay off their loans more easily.

We should absolutely invest in community colleges. We just need to think carefully about how we do it.