From robot cookie makers to lightbulbs that double as phone chargers, Silicon Valley is great at selling us random gadgets we didn’t know we need. And while it’s cool if you’re into automated pita bread warmers of the future, it’s what happens after you put these devices through the test of time that these startups are less helpful with.

New research by the engineering lab team at the University of California, San Diego is hoping to fix that by creating magnetic ink particles that could self-heal devices when they break. Sensors printed with this ink would magnetically attach to each other when a rip or tear occurs, automatically fixing a device at the first sign of disintegration.

“Just like the human skin is stretchable and self-healing, we wanted to impart a self-healing ability to printed electronics,” Amay Bandodkar, a member of the research team, tells The New York Times.

“Within a few seconds it’s going to self-heal, and you can use it over and over again.”

The published study focused on creating sensors that can be incorporated with fabrics. The result is smart clothing that can repair cuts up to three millimeters long in 50 milliseconds. In a sample video, a sensor used to light a small bulb gets snipped in half. In seconds, magnets in the sensor pull the two sides back together and slowly light the bulb again.

To create the self-healing effect, the team used pulverized neodymium magnets typically found in refrigerators and hard drives and combined them into the ink. This helps the researchers avoid the traditional process of adding chemicals and heat, which could take hours to complete.

Bandodkar estimates that $10 worth of ink can create “hundreds of small devices” that can help reduce waste, since you won’t need to throw these wearables and gadgets out when they’re broken. “Within a few seconds it’s going to self-heal, and you can use it over and over again.”

The team is currently evaluating the best ink ratios to use for different gadget-printing applications, with the goal of using them to create anything from solar panels to medical implants. And perhaps soon enough, the technology will trickle down to everyday gadgets that won’t require you to call customer service for minor part replacements.