A prominent media event during President Barack Obama’s visit to Brazil will be an outing to one of Rio de Janeiro’s favelas, a slum neighborhood often ridden by drug-gang violence.

The favelas, containing a million people, a sixth of Rio’s population, have been neglected for decades, even though they are scattered throughout the city, including in some of its prime sections. Inhabited by descendents of slaves and manual laborers brought to Rio for construction and other menial jobs, favela residents were not given an opportunity to break out of their condition of marginalization, poverty, and intense crime. Education in these slums is often dismal, way below the already-poor quality of Brazil’s primary and secondary public schools education. Public services, such as clean water, sewage, electricity, internet access, health clinics, access to justice and dispute resolution mechanisms, and roads have been grossly underprovided. To the extent that if some of these services did arrive in a particular favela, they were frequently limited political handouts negotiated between a Rio politician and a favela leader: in exchange for being guaranteed the community’s votes, the politician would promise to provide a water reservoir or pave a road in the favela.

Most significantly, public security, the irreducible responsibility of a state, was never provided in the slums. Festering without legal jobs and safety in their alleys -“streets” would be a too generous a term for the unpaved pathways among flimsy shacks and mud houses – that wind their way up steep hills, the favelas consequently became areas of local drug distribution. From the mid-1980s on, they were progressively taken over by drug gangs, such Comando Vermelho (CV) or Primeiro Comando da Capital (PCC). Having emerged from prison gangs and with continually strong relationship to Rio’s prison population, the gangs took over social life in the favelas. These gangs could organize the economic activity, such as monopolizing “public” transportation in the form of motorcycle taxis and minibuses within and to the favelas, regulating street crime, running courts and disbursing justice, providing social services handouts, and dictating who in a community could organize and how. The gangs also established boundaries between their sections of control that the residents couldn’t cross.

The militias that emerged in Rio in the 2000s, supposedly to combat the drug gangs, have often taken over the various rackets in favelas, behaving with greater brutality towards the residents than the gangs do. And to the extent that police, notorious for its violence, would enter the favelas at all, either to collect bribes or to conduct highly violent raids which left hundreds of bullets holes and many dead behind. The drug gangs often responded with greater firepower, even shooting down a police helicopter a few years ago. When Cariocas (as the non-favela residents of Rio are known) snuck into to the favelas, it was to buy drugs. Mostly, they preferred not to think about the favelas and to have the police suppress them and the crime in Rio they inevitably blamed on favela residents.

The so-called “Pacification” Plan (UPP) that President Obama will be shown in the favela he visits is supposed to change these problems by suppressing the drug gangs and integrating the slums into the rest of Rio physically and hopefully also socially. First, heavy police forces, the BOPE, take over a favela, capture the drug gang members and imprison at least their leaders; foot soldiers sometimes have a chance to go through a demobilization process run by NGOs. After some time, BOPE hands security over to community police who try to get to know the residents and their concerns and provide steady public safety. Then social services and public goods are supposed to arrive.

Does this sound like a classic counterinsurgency? And like a classic counterinsurgency, the process suffers from many glitches – from problems with the security handoff by BOPE to the community police, to establishing community trust in the police, to providing social services systematically, to providing legal jobs, and to having sufficient police and economic resources to pull off the state-building and social development effort in all of Rios’s favelas. Last year when I visited one of the first favela subject to UPP – Babylonia — I found that its residents mainly stayed away from the community police and had many complaints. They bemoaned that street crime increased dramatically; the promised road paving had not taken place several months after the favela was “cleared” from the CV and the provided internet server stopped working two months after it was delivered.

Still, life in Babylonia a year ago was much better than in the Alemao-Villa Cruizero complex where I also conducted research. Drug gang members there guarded the entrance to the favela with machine guns. Inside the bullet-ridden square, cocaine was sold completely in the open. While I was there, a big tropical, of the kind that regularly washes away many favela houses and kills hundreds at a time, came through. The narrow alleyway that my guide and I were walking downhill became a dangerous knee-high torrent of water, sewage, and trash. But the–six-to-eight-year-old boys—there were not deterred. With an old beaten-up boogie board they had found on one of Rio’s famous beaches (usually inaccessible to them), they surfed on the torrent of sewage with great delight. At the bottom of the surfing alley where they landed stood a bunch of the older boys (drug gang members) weighted down with machine guns and belts of grenades. The boys’ surfing was testimony to the resilience of human spirit even under great hardship. UPP promises to give those younger boys perhaps the greatest chance they have had so far to not end up carrying machine guns and engaging in urban warfare against the state and with rival gangs when they turn 16.

This year several of the favelas where UPP has been implemented participated for the first time in decades in Rio’s carnival with their own floats. Their residents optimistically spoke about the coming social integration of Rio. From the perspective of Brazil’s government, President Obama’s visit to a favela is an endorsement of the success of the program, which the Brazilian government has announced that will be emulated in other Brazilian cities. For the favela’s residents, Obama’s visit is at least an affirmation that they are no longer ignored. For President Obama, it is an opportunity to emphasize his administration’s focus on social development in Latin America.

Whether UPP truly transforms the violent ghettos into regular parts of Rio remains to be seen. The hardest part – bringing in social opportunity and establishing legal jobs – comes only after the BOPE forces clear out the drug gangs. Perseverance with the social development programs and police reform is necessary. If the development and public safety efforts are abandoned once the World Soccer Cup and the Rio’s Olympics are over in 2016, it is easily possible that the favela boys will soon be surfing on sewage once again.