While running Molly’s, the Seattle-based ready meal wholesaler he founded, Stefan Kalb was upset about its 28 percent food wastage rate. Feeling that the amount was “astronomical,” he began researching how to lower it — and was shocked to discovered Molly’s was actually outperforming the industry average. Confronted by the sheer amount of food wasted by American retailers, Kalb and Bede Jordan, then a Microsoft engineer, began working on an order prediction engine.

The project quickly brought Molly’s percentage of wasted food down to the mid-teens. “It was one of the most fulfilling things I’ve ever done in my career,” Kalb told TechCrunch in an interview. Driven by its success, Kalb and Jordan launched Shelf Engine in 2016 to make the technology available to other companies. Currently participating in Y Combinator, the startup has already raised $800,000 in seed funding from Initialized Capital, the venture capital firm founded by Alexis Ohanian and Gerry Tan, and is now used at more than 180 retail points by clients including WeWork, Bartell Drugs, Natural Grocers and StockBox.

Shelf Engine’s order prediction engine analyzes historical order and sales data and makes recommendations about how much retailers should order to minimize waste and increase margins. The more retailers use Shelf Engine, the more accurate its machine learning model becomes. The system also helps suppliers, because many operate on guaranteed sales, or scan-based trading, which means they agree to take back and refund the purchase price of any products that don’t sell by their expiration date. While running Molly’s, Kalb learned what a huge pain point this is for suppliers. To alleviate that, Shelf Engine itself buys back unsold inventory from the retailers it works with, taking the risk away from their suppliers.

Kalb, Shelf Engine’s CEO, claims the startup’s customers are able to increase their gross margins by 25 percent and reduce food waste from an industry average of 30 percent to about 16-18 percent for items that expire within one to five days. (For items with a shelf life of up to 45 days, the longest that Shelf Engine manages, it can reduce waste to as little as 3-4 percent).

The food industry operates on notoriously tight margins, and Shelf Engine wants to relieve some of the pressure. Running Molly’s, which supplies corporate campuses, including Microsoft, Boeing and Amazon, gave Kalb a firsthand look at the paradox faced by retail managers. Even though a lot of food is wasted, items are also frequently out of stock at stores, annoying customers. Then there is the social and environmental impact of food waste — not only does it raise prices, food rotting in landfills is a major contributor to methane emissions.

A store manager may need to make ordering decisions about thousands of products, leaving little time for analysis. Though there are enterprise resource planning software products for food retail, Kalb says that during store visits he realized a surprisingly high number still rely on Excel spreadsheets or pen and paper to manage reoccurring orders. The process is also highly subjective, with managers ordering products based on their personal preferences, a customer’s suggestion or what they’ve noticed does well at other stores. Sometimes retailers get stuck in a cycle of overcorrecting, because if customers complain about missing out on something, managers order more inventory, only to end up with wastage, then scaling back their next order and so on.

“Americans want selection at all times, we get furious when a product is sold out, but it’s a really hard decision to make about how much challah bread to stock on a Monday,” says Kalb. “Yet we are doing that ad hoc.”

When retailers use Shelf Engine’s prediction engine, it decides how many units they need and then submits those orders to their suppliers. After products reach their sell-by dates, the retailer reports back to Shelf Engine, which only charges them for units they sold, but still pays suppliers for the full order. As time passes, Shelf Engine can make more granular predictions (for example, how precipitation correlates with the sale of specific items like juice or bread).

In addition to providing the impetus for the creation of Shelf Engine, Molly’s also helped Kalb and Jordan, its CTO, build the startup’s distribution network. Kalb says Shelf Engine has benefited from the network effect, because when a retailer signs up, their suppliers will often mention it to other retailers that they serve. Kalb says the startup is currently hiring more engineers and salespeople to help Shelf Engine leverage that and spread through the food retail industry.

“It’s a world I got to know and I came into the world fascinated with healthy food and making delicious grab-and-go meals,” says Kalb. “It turned into a fascination with this crazy market, which is so massive and still has so many opportunities to be maximized.”