A wave of closures has swept bricks-and-mortar retailers around the country this year. BankruptcyData, a research service, has already counted 328 retail bankruptcy filings in 2017, compared to just 251 during the same period last year.

Oren Teicher, CEO of the American Booksellers Association, has been “carefully” watching the retail situation and hasn’t seen a catastrophe for bookstores. “ABA membership numbers have shown some modest growth over the past several years, and that’s continued through this year,” he noted. His organization has counted 10 new member locations so far in 2017.

Kepler’s Books CEO Praveen Madan, on the other hand, has been preparing for the worst for years. “[Booksellers] have to begin by accepting that their business models face serious existential threats,” the Bay Area bookseller explains. Madan took over as CEO of Kepler’s at the end of 2011 as the bookstore (founded by Roy Kepler in 1955) teetered on the brink of closure. Borders had just declared bankruptcy, e-book sales had exploded, and the demise of print was widely predicted.

Five years later, Madan (who is also co-owner of San Francisco’s Booksmith) and his team have transformed the bookstore—following a “Kepler’s 2020” strategy designed to allow the store to survive in this difficult retail environment. The reboot began with a fund-raising campaign that collected $730,000 in start-up capital for the bookseller. Madan and his team negotiated a more affordable lease for the bookstore’s Menlo Park storefront, restructured its real estate footprint, upgraded its bookselling technology, and refreshed its inventory.

“There are lots of things [booksellers] can do to improve their store’s fundamentals and increase the likelihood of surviving,” Madan noted. Instead of offering blanket advice for booksellers, he posed a series of questions that, he said, individual stores should ask, including, “What are your community’s unmet needs or pain points that your bookstore is in a unique position to address?”

The Kepler’s 2020 plan created the Kepler’s Literary Foundation to handle events and to better engage the community. The foundation, which was spun off earlier this month as an independent nonprofit, offers writing classes, youth programs, workshops, and community discussion groups.

Madan also urged booksellers to ask, “What unique purpose can your bookstore serve?” In this vein, Kepler’s acquired GiftLit, a subscription service that helps book lovers send age-appropriate gift-wrapped books to friends and family. This has become a key piece of business for the bookstore, a human, customized experience that algorithms cannot provide. “In two years, [GiftLit] essentially doubled in size,” Madan said. “There’s no other part of the business at Kepler’s that’s growing at that rate.”

“What are the core skills or resources you wish you had access to, and how can you find them in your community?” is Madan’s final question for booksellers. Kepler’s connected with a powerful ally to seek out new digital resources: earlier this year, fellow Menlo Park business Facebook gave Kepler’s a seat on its U.S. Small Business Council, picking it from among the five million businesses that use Facebook as an advertising tool.

The council’s 35 member companies hail from all over the country, from a skateboard shop in California to a gourmet burger restaurant in South Carolina. Members get a first look at new business tools from Facebook and a chance to take part in press and speaking opportunities. Recently, Madan and Kepler’s special projects director Nicole Hughes spent two days at Facebook headquarters, meeting with product and marketing teams to learn more about the platform.

Madan is “90% confident” that Kepler’s will survive for at least the next five to 10 years, but he doesn’t have much hope for the long-term prospects of old-fashioned bricks-and-mortar bookselling. “I have a hard time imagining how anyone, including Kepler’s, is going to be able to get much growth out of a traditional retail business,” he said.

In contrast, ABA’s Teicher said he’s heard dire predictions for 25 years, but remains “guardedly optimistic” about the future. “If I look at the most successful indie bookstores in the country, one of the hallmarks of those stores is that they have evolved.” He concluded, “Flexibility and recognition that you’ve got to change and adapt is at the core of our continued success.”