In the Cengkareng Drain, a river that runs through the megacity of Jakarta, Indonesia, tons of plastic trash flows to the ocean each year. But now a new solar-powered robot called the Interceptor is gobbling up the waste so that it can be recycled instead.

The system was designed by the nonprofit The Ocean Cleanup, which spent the past four years secretly developing and testing the technology while it continued to work on its main project—a device that can capture plastic trash once it’s already in the ocean. The nonprofit unveiled the Interceptor at an event in Rotterdam today.

The ocean’s plastic trash problem often starts in rivers: Every year, as much as 2.4 million metric tons of plastic flows from rivers to the sea, the nonprofit estimates. Most of that trash comes from rivers in Asia, in cities where recycling infrastructure is often inadequate. Around 1% of the world’s rivers, or 1,000 rivers in total, are responsible for the majority of the trash entering the ocean. And while countries and companies try to make more fundamental changes—like reusable and refillable packaging, single-use packaging bans, and recycling systems that actually work—it’s clear that tackling the problem in rivers is one part of the short-term solution.

“When we think about solutions, we obviously need to think holistically,” says Nick Mallos, senior director of the Trash Free Seas program at the environmental nonprofit The Ocean Conservancy. “First and foremost, we need to move all the way upstream and reduce consumption and production of single-use, unnecessary plastics, and we need to better collect and recycle plastics and ensure materials are getting back into the supply chain for a circular economy. But then for the materials that are still escaping and currently not making their way in that system, the last line of defense is cleanup.” When it comes to cleanup, he says, it’s also far more effective to start on beaches and on rivers rather than trying to tackle the problem in the middle of the ocean. The Ocean Conservancy, which conducts beach cleanups, is also beginning work on a river cleanup system in Vietnam.

The new technology is designed to anchor to a riverbed, out of the path of passing boats. Like the system that the nonprofit designed for the ocean, which uses a large barrier that blocks part of the river to collect plastic as it floats by, the Interceptor has a floating barrier that directs trash into the system. The device is positioned where the greatest amount of plastic flows, and another device can be placed in farther down the river to catch trash that might escape the first Interceptor. A conveyor belt pulls the trash out of the water, and an autonomous system distributes it into dumpsters on a separate barge, sending an alert to local operators when the system is full and ready to be taken to a recycler. The system runs on solar power. In a typical day, it might extract as much as 50,000 kilograms of trash; depending on the currents, tides, and how much plastic is in a given river, The Ocean Cleanup estimates it could theoretically collect as much as 100,000 kilograms.

The machine isn’t the first to be designed to tackle river waste. In Baltimore, for example, the cartoonish-looking Mr. Trash Wheel scoops plastic bottles and bags out of a river leading to Baltimore Harbor. But The Ocean Cleanup saw the need for a device that could more easily scale up; since it runs autonomously, it needs little human interaction and also doesn’t require humans to sort through potentially dangerous debris collected from the water. It’s designed to be mass-produced. The nonprofit aims to deploy it into all of the most polluting rivers in the next five years. Right now, in addition to the system in place in Indonesia, another is installed in a river in Malaysia, and two others are planned for Vietnam and the Dominican Republic. Others are likely to follow next in Thailand, the West Coast of the U.S., and El Salvador.

Simultaneously, the nonprofit is continuing work on the ocean system that it is currently testing in the Great Pacific Garbage Patch, which it recently announced is beginning to collect plastic after some engineering challenges. Both ocean and river solutions are necessary, the team argues. “We project that we can remove 90% of floating ocean plastic by 2040, and to truly rid the world’s oceans of plastic we must do two things: cleanup legacy plastic and stop it from entering the ocean,” they wrote in a press release. “Both are necessary to achieve this mission, so we will continue our efforts in the ocean to ensure its safety and health for the future. Because plastic in the oceans is persistent, the only way to reduce the amount of plastic in the oceans is to also clean up the legacy. No ocean cleanup, no clean ocean.”