More than two weeks after Hurricane Maria crashed into Puerto Rico on Sept. 20, Allan Rivera had still not had a full night’s sleep. “Every three hours … I get up and do some maintenance on the generator,” he told me. His wife — who has multiple sclerosis — relies on air conditioning to help minimize her symptoms, but Toa Baja, the town where he lives on the island’s north coast, was still without electricity. That meant Rivera had to keep a gasoline-powered generator running 24 hours a day, seven days a week.

This is a cruel irony for Rivera, the president of a Puerto Rican organization that advocates for renewable energy. And it’s a situation that he and many other Puerto Ricans are likely to be stuck with for some time. Maria knocked out all of the island’s electricity. As of Friday, only 9 percent of Puerto Ricans had gotten it back. But that number isn’t stable — over the course of the week it went from 16 percent, to 10, and back up to 17 percent before falling. Two days after the storm, experts on the island said it could take four to six months to restore service. Rivera told me he was hearing that it could be eight months to a year before the whole island — big cities, small towns and rural countryside — is electrified again.

Puerto Rico’s electric grid was in bad shape before the storm. But that fact was more than just a portent of doom: It’s also a harbinger of what’s to come. The system failed so spectacularly because it was stuck in a downward spiral of increasingly poor service. And that spiral is going to be difficult to escape during the rebuild. Despite a number of nonprofit and for-profit groups interested in designing a renewable, resilient replacement grid, stories like Rivera’s are unlikely to end in a feel-good engineering fairytale — at least not anytime soon.

Electricity is generally a reliable service in the United States. Data from 2015 shows that, on average, Americans could expect a little more than three hours a year in which their electricity wasn’t working properly. But Puerto Rico is a different story. There, the 2015 goal of the Autoridad de Energía Eléctrica — a government agency that owns the island’s electric distribution system and much of its generation capacity — was to have no more than 9.6 hours of outage per customer, and the utility still wasn’t able to meet that goal. At the same time, Puerto Ricans pay higher prices for electricity than almost everyone else in the U.S. — nearly 20 cents per kilowatt-hour for residential customers, compared with a U.S. average of about 13 cents per hour. In July, only three states paid more.

That combination of poor service and high prices is partly a function of living on a mountainous island and partly a result of the economics and politics on Puerto Rico, said Jose Maeso, who was the executive director of the Puerto Rico State Office of Energy Policy from 2013 to 2016 and is now the director of a Department of Energy-funded research consortium. There are universal challenges to running an electric grid on a tropical island. Salt vapor in the air corrodes electric equipment. Forests grow up quickly and are hard to keep away from power lines, especially in rural areas. Rural electrification, in particular, has been a challenge for Puerto Rico, Maeso told me. Outside narrow swaths of coastal plain, the island rises up in mountains and cliffs. Electrical lines were built through this terrain, Maeso said. And some of those lines pass through regions where there isn’t good road access, increasing the difficulty of doing maintenance and repairs. It’s no coincidence that two of the three states with higher electricity rates than Puerto Rico are Alaska and Hawaii, which offer their own logistical challenges for electricity production and distribution.

Being an island has also, historically, limited the types of energy resources Puerto Rico could use and raised their cost. The island’s electricity is almost entirely generated by burning fossil fuels, mostly oil — and all of that fuel has to be imported. When the cost of oil goes up, so do electric bills. Even if you burn natural gas — which is a cheaper energy source than coal or oil — that still costs more when you have to haul it across an ocean. Until 2012, the Autoridad de Energía Eléctrica didn’t have facilities that could burn natural gas, anyway.

All of this helps to explain why Puerto Rico’s grid was in such bad shape before Maria hit — and why it will take so long to rebuild. The AEE has long been under political pressure to not raise prices, said José Román Morales, interim president of the Puerto Rico Energy Commission, a government body formed in 2014 as a regulator for the AEE and private electric generation companies. That made sense in some ways: Electricity is crucial, and Puerto Ricans, in general, don’t have a lot of spare cash — the median income is just $19,350, and more than 40 percent of the population lives below the poverty line.

But those pressures, combined with the realities of running an electric grid on an island, created problems. The AEE didn’t raise its base rate — the part of the electric bill that’s meant to cover basic operating costs and maintenance — between 1989 and January 2017. But the price consumers actually pay — the total bill — still went up over that time period because of rising fuel prices. Puerto Ricans became trapped in a feedback loop where the AEE had less and less money to keep the grid working well, but consumers had more and more reason (from their perspective) to demand that the agency not raise rates.

Making matters worse, the lack of cash for maintenance has made maintenance more costly than it would otherwise be. Before Hurricane Maria, most of what was getting done was reactive maintenance — fixing immediate outages — not preventative maintenance or upgrades, Morales said. That means AEE’s equipment — from its power plants on down — is old and out-of-date. The median age of an AEE power plant is 44 years, compared with an electric industry standard of 18. “They suffer mechanical failures constantly,” Morales said. “They have to wait a long time to get parts, and the original manufacturers consider them like a speciality part.” Even workers with the expertise to manage these aging units are in short supply and retiring quickly.

Not having enough money creates a system that is more expensive to operate, which results in even tighter budgets. It’s not going to be easy for Puerto Rico to get out of that cycle, especially with a history of mismanagement by AEE that’s left such spotty records and data analysis that a 2016 independent expert review of AAE’s operations and finances concluded that the utility can’t accurately predict its own upcoming customer demand.

In the U.S., if you’re already poor, the same services can often cost more than they would for people in better financial circumstances. The media often refers to this with the maxim “it’s expensive to be poor” — and there’s something similar going on with Puerto Rico’s grid. Puerto Ricans don’t have much money, which puts pressure on the utility to not raise rates, which makes the system more expensive to operate, which drives the utility into debt, which forces it to spend money that should have gone to maintenance on the costs associated with just keeping its head above the financial waves.

The 2016 expert review noted that the utility was spending more than $100 million a year — more than its entire proposed budget for the cost of generating electricity in 2017 — on unnamed miscellaneous expenses. When I asked Morales if there was any indication what those expenses were, he said AEE staff had explained during a hearing that this money was being spent on debt service, fees and legal bills — all costs incurred because the utility was so short on funds.

So what happens next? Despite hopes for the future, Puerto Rico is, once again, forced to focus on reactive maintenance. “There is no time to redesign the system or apply new technologies at a large scale now,” Carlos Reyes, general manager of operations for EcoEléctrica, a private company that operates one of the few power plants not owned by AEE, told me in an email. Other experts agreed. It’s unlikely that Puerto Rico’s grid will be rebuilt stronger and better over the next year. It’ll be enough work just to get it back online in its same old state.

The work of reimagining the grid — and, more importantly, designing a system that won’t put people right back in the dark the next time a hurricane hits — will take more than just technological improvements. Puerto Rico will need to reimagine the system that led to outdated, run-down technology, too.