“It was a beautiful poem,” Steve Parrott told me. Parrott is the CEO of Legacy.com, the biggest obituary website in the country. This poem was a loving, touching tribute to someone who had died — a positive memorial, save for one small thing.

“But if you were to break down the poem, the uppercase letters all spelled a very nasty word,” Parrott said. “W-H-O-R-E.”

As a matter of respecting the deceased, Legacy.com rejects about 400,000 inappropriate comments left on people’s eulogies a month. But in the three and a half years that Parrott has been at the company, he can recall a handful of close calls that almost snuck through. This year, the poem was a particular standout, the 52-year-old told me when we sat down on two of a cluster of thick leather couches in his spacious office, where a metal skull faced us from the window sill. It was part of the 18-year-old website’s new “Innovation Lab” in Calabasas, California.

When it was first submitted, the poem was subtle enough to sneak by the algorithm that Legacy created to catch the incredible amount of religious spam, revenge notes, and profanity that is submitted as “guest book” entries to the site’s obituaries every day. Then it was routed into Legacy’s three-tiered review system, a process during which several content screeners — drawn from a part-time staff made up of people Parrott describes as bloggers, stay-at-home moms, and retirees — looked it over. It was only in the late stages of this process that a moderator noticed something amiss and intervened. The poem was rejected. The site’s engineers later added a rule to the algorithm to flag comments that randomly capitalized letters. Yet another potential posthumous digital crisis was averted.

“You would think that after 18 years, we’d have seen it all,” Parrott said with the frankly familiar detachment of someone who deals with dark internet behavior every day. “But we haven’t.”

Such is the daily dance of Legacy, a massive online repository for obituaries that strives to honor the tradition of remembering the dead while also dealing with a generation of online users who have claimed the Dick Butt as their unofficial mascot. Since the late 1800s, obituaries have existed as a sacred step of the mourning process, an honored tradition that came in the form of memorial cards that were sent around town, or, in recent history, a few carefully edited columns in the local newspaper. But these days the internet has complicated the matter of dying, especially when it comes to announcing it. The format of a person’s obituary must be all at once Google-friendly, easy for loved ones to access and share memories on, and heavily regulated. (The alternative is often a Facebook page that can devolve into a comment cesspool.) And, as with everything that exists on the internet, online obituaries must make their host money by providing information on both the deceased and the people who mourn them. It follows that Legacy has turned to data science, crowd-sourcing, and multimedia tools, reimagining the obituary for the modern era.

Legacy is not the only website in the business of digital memorials, or the most innovative — but it is the largest in the country. It began in 1998 as an online destination that republished obituaries from major publications. Over the years, as it partnered with thousands of newspapers and funeral homes from around the world, the site became a go-to archive for information about the deceased. Today, Legacy is home to roughly 100 million obituaries. In addition to acting as a digital tombstone for about 7,000 newly deceased people each day, the company offers print “condolence books” composed of memories left by people on the site. Legacy’s high Google PageRank for the search term “obituary” has led it to fill its homepage with advice columns from the “Dear Abby of death,” and the latest news about famous deaths. (When Prince died, the website livestreamed his funeral from the homepage. When René Angélil died, Legacy acted as the official sponsor of his memorial book, an eight-volume, leather-bound collection of memories people submitted through the site that Legacy delivered to his wife, Céline Dion.)

Parrott estimates that about half of the 200,000 people who die each month in the U.S. end up with an obituary on the site, a steady volume of new entries that contributes to the site receiving about 20 million unique U.S. visitors per month. As a result, Legacy’s annual revenue falls between $20 million and $100 million, according to Parrott, and comes from a mix of services and ads. The site’s newspaper partners pay a fee for their obits to be posted, but share half the ad revenue from those pages. Legacy also generates profit from the bright orange “Send Flowers” button it plops onto the eulogies of the recently deceased. And for non-celebrities, soft- or hardcover guest books that contain the comments on a dead person’s page start at $24 and $31, respectively. Despite its somewhat outdated format and feel, Legacy is the closest thing we have to a Facebook or LinkedIn that exists explicitly for the dead.

“It’s interesting how predictive it is,” Benjamin Anik, a 29-year-old senior web design manager at Legacy, told me, referring to the prime time for flower and guestbook sales on a person’s page. “You know that after the death, anything between zero and seven [days] is like our golden time to get it up there. The sooner we get it up there, the more money we make, the more guestbook entries, the more flower sales, the more involvement. Anything past that, it starts to dwindle very quickly.”

The site’s vast pool of unused information inspired Parrott to jump-start the company’s very first Innovation Lab in February of last year. The team is comprised of data scientists, user experience designers, and programmers, all housed in a two-story complex of cottage-like doctor’s offices. It’s no Silicon Valley — Calabasas is a posh L.A. suburb best known for its Kardashians and mini-malls — but Parrott has used his past experience as a startup founder and the president of CNET’s Content Solutions branch to establish an environment that mirrors the signature tech culture of Bay Area companies. And, despite hailing from Canada, Parrott himself seems to exude all the relaxed markers of a Californian entrepreneur. His demeanor is casual and measured, his gray hair receding, one wrist strapped with an expensive watch, the other with a Fitbit. And he is not afraid to wax poetic about the good his company has done for the world.

“I got the phone call from a recruiter for this job three and a half years ago,” he said, when I asked how he had ended up leading America’s largest obituary archive. “And I’m like: ‘Are you crazy? I work at CBS, why would I want to work for a death site?’ Then you think about it and you’re actually taking technology to this historic document, the obituary. You see, I don’t want my Facebook page to be what my grandkids see about me. Is my LinkedIn all I’ve accomplished? … This is something that’s broader than just this particular funeral home chose to share it or not share it. There’s more to the story: being able to reach everyone.”

Parrott has adopted the same idealism in an attempt to recruit new talent. Legacy’s Innovation Lab, according to its website, embraces “the quirks that make people unique” and doesn’t “believe in limits.” It has grown from four to 32 employees over the course of a year, and its accommodations have expanded alongside the staff. The lab’s kitchen is packed with free boxes of Cinnamon Toast Crunch, M&M dispensers, cold San Pellegrinos, and a well-equipped coffee machine. The common room outside Parrott’s office, where employees are served free pizza on Tuesdays, is furnished with couches, an old-school arcade console, a dart board, and a requisite ping-pong table. Conference rooms are lovingly named after L.A. freeways. The afternoon I stopped by, the shades were drawn in the upstairs office where most of the engineers were working, as if it were a college dorm on a Saturday morning. A Bart Simpson doll, a squirt gun, and a drone were strewn across a nearby table.

There are also reminders of the fleeting nature of human existence. Mock-ups of redesigned webpages on the walls feature the names and photos of actual dead people, sourced from the site’s entries. Employees are typically on alert for the latest high-profile death. Though Parrott is quick to emphasize that the company wants “to celebrate life,” the subject matter can occasionally be grim.

“Having been at this company for so long, the majority of my Facebook feed is now tragedy- and death-related stuff, just because of [Facebook’s] algorithms,” Anik, the web design manager, told me during my tour of the office. “Sometimes I’ll be watching a video that some site has made and I’ll just be sobbing. My boyfriend’s like, ‘What are you doing? Why do you cry so much?’”

Parrott founded the lab to put the company’s 18 years’ worth of archives to use, updating what he admits was an ancient site so it can collect as much information as possible on both the deceased and their — for lack of a better term — mourning networks. That means using an algorithm to sift through the text of existing obituaries and pick out key facts relating to a person’s identity: where they lived, worked, worshipped, and attended school. Engineers also built smart questionnaires into the comment section, providing visitors who want to share memories with prompts regarding their relationship to the deceased.

“The approach that we are taking is mine all the data that we already know, whether it’s from an obituary, or from other related obituaries, or the people commenting,” Parrott said. “If you prompt people for simple questions, they can then engage with those questions. As opposed to ‘tell me what you like about Bill.’”

Ultimately, establishing these dossiers is not only meant to enrich a person’s obituary, but also to help Legacy provide the same automated suggestions and notifications that users have come to expect on sites like Facebook, Amazon, and LinkedIn. One such recently added feature, for instance, mirrors the “People Also Viewed” section that sometimes pops up along the side of a LinkedIn profile. Legacy’s version is to surface relevant obituaries for users who regularly browse the site. Basically: If you read one person’s obit, you might like this one, too.

“If we find that Person A has left five condolence messages over the past couple of years, and Person B has left five condolence messages, and they’re all for the same five people, then there’s a good chance that A and B have similar interests,” Parrott said, evoking a kind of grim logic puzzle. “So if somebody just died that A has a message for, we let B know.”

In all of these updates, Legacy’s product team must carefully navigate the often murky social rules for how to respectfully mourn a person online. To address this they have studied the people who have visited their site via browser cookies: who they are, what they like to read, what they like to do. With that information they have created a brand book of personas — including titles like “the coach,” “the historian,” and “the 35-year-old mom.”

“We have all of these different personas,” Parrott said. “But generally they’re doing one of two things. Somebody has died, and they want to come and pay their respects. Or they are the browser who comes back every single day and reads from top to bottom everyone who has died.” It is according to this information that the company’s designers are able to adjust the site to different visitors. So, if you are a young person who visits Legacy as result of a Google search, you won’t be targeted with advertisements for other relevant obituaries (the logic being that you are visiting Legacy to mourn just one person). The site might also be displayed in a smaller, or more modern, font.

The company has not always been so responsibly prescient. A few years ago, the product team had an idea to send notifications out for the one-year anniversary of a person’s passing via its opt-in ObitMessenger service. Unfortunately, it seemed that what exactly users had opted in to wasn’t clear and Legacy learned the hard way that people were upset by the alerts. As Parrott put it, the general feedback was: “Are you trying to say that you think I forgot my mom died a year ago today?” From then on, immediate family members were left off the alerts.

But Legacy has gotten undeniably smarter. Parrott envisions eventually transforming the entire look and feel of the company’s obituaries — or, as Parrott calls them, “Life Stories” — for the digital age. Though the redesigned obits remain a distant goal, he envisions them not as webpages, but “experiences” made up of images, videos, and audio clips that encapsulate the essence of a person’s life and passion.

“It’s going to be a lot more than just reading a bunch of words,” Parrott said. “There has to be something more to it than that, so when a generation or two from now goes back and wonders who I was, they can get a real sense. What was really important to me? What did I value? What did I cherish? A Google search is not going to help do that.”