The process is called “culling” by the industry and involves either grinding the male chicks while still alive, gassing, or asphyxiating them. The birds are considered useless since they (obviously) can’t lay eggs, are slow-growing, and don’t produce a lot of meat like breeds specifically raised for the broiler industry.

O’Hayer was shocked by what he learned – after all he’s a vegetarian whose company is focused on providing a humane alternative to industrial-scale egg production by ensuring the 100 farms across six states his company works with give their chickens a good life, including fresh pasture, room to roam, and other high welfare standards. He tried various ways to try to save the male chicks, including a plan to send a bunch to Haiti following the devastating 2010 earthquake, but none of these ventures worked. So O’Hayer took another track and turned to science for the answer.

This is a very promising technology that could spare millions of animals from a gruesome fate.

The result is called TeraEgg, a technology that uses a type of infrared light called a terahertz wave that, with the help of a special algorithm, is able to detect biological markers that determine the gender and fertility in the very early stages of the embryo development process. The technology will allow the hatcheries to remove the male and infertile eggs on the day they’re laid, before they go into incubation, so they can instead be used for human consumption, O’Hayer tells Modern Farmer in a phone interview.

“The benefits are wide ranging, from the animal welfare perspective, the hatchery perspective, and the food waste perspective,” O’Hayer says. Vital Farms partnered with Israeli tech company Novatrans to create a subsidiary company called Ovabrite to market the technology, which they hope to have commercially available towards the end of 2017.

While O’Hayer is coming at the problem from an animal welfare perspective, he says there’s also a financial incentive for the hatcheries to embrace the technology; they’re one of the few businesses in the world that throw away 50 percent of what it manufactures, plus spends time and energy producing what they consider a worthless product. Plus, he says, there’s the food waste that comes from throwing away seven billion eggs that could be food.

Paul Shapiro, vice president of policy for the Humane Society of the United States, says they are “rooting for” TeraEgg’s success. “This is a very promising technology that could spare millions of animals from a gruesome fate,” he tells Modern Farmer in an email.

Shapiro points to the 2014 Unilever announcement that it wanted the egg industry to find a solution to the male chick culling problem as helping to “set the path for the innovations we’re now seeing.” Unilever, which owns the Hellmann’s brand, is the largest producer of mayonnaise in the world. In June, United Egg Producers, which represents about 95 percent of all egg farmers in the country, said it would embrace the new technology when it became available and economically feasible with a goal of ending the culling practice by 2020.

TeraEgg isn’t the only technology being developed to stop male chick culling. Egg Farmers of Ontario has been working with Michael Ngadi, a professor of bioresource engineering at McGill University, on an embryo gender-detecting technique and hopes to have a prototype ready by the end of this year. In Germany, there’s a government-funded research project developing another technique. There’s also Project In Ovo, a Dutch startup working on yet another way to detect gender in eggs. O’Hayer says there’s “probably room for everybody” in the market but hopes to get TeraEgg out quickly and into the hands of hatcheries in order to stop the needless killing of billions of chicks.

“Fortunately, we’re all on the same page when it comes to results because everybody wins in this one,” says O’Hayer. “That’s pretty exciting.”