In the West African countries of Guinea, Sierra Leone and Liberia, the Ebola virus is “out of control,” to quote a phrase used frequently during the outbreak, including by the World Health Organization in a statement on Tuesday.

In the West African countries of Nigeria and Senegal, the virus appears very much in control. The outbreak could be declared at an end in Senegal by Friday, and in Nigeria by next Monday, WHO said.

Health officials in Nigeria and Senegal had several advantages over their counterparts in Guinea, Sierra Leone and Liberia. Importantly, they detected the outbreak when it had affected just one known person, making it feasible to attempt to track all of that person’s contacts. Spain and the United States, despite their missteps so far in protecting and monitoring health workers, also have that going for them.

The three hardest-hit countries all first showed up in WHO outbreak reports after they had identified several people who had contracted Ebola — 49 in Guinea, then eight in Liberia and 16 in Sierra Leone (after some prior reports in the country didn’t pan out). But Senegal and Nigeria each registered with international health officials when they had identified a single case. And now each country is approaching the threshold set by WHO for declaring the outbreak over: 42 days with active surveillance and no new cases.

Health officials gain a big edge in their race against the virus if they can start with just one patient. There’s the obvious advantage of having to trace only one person’s contacts, and those contacts’ contacts. Then there’s the benefit of time, which means fewer iterations of contacts to monitor.

Even with those advantages, controlling the virus isn’t easy, as the United States learned on Wednesday when it was reported that a nurse just diagnosed with the virus — the second person to come down with Ebola in the U.S. — had flown on a commercial flight with 131 other passengers. Still, a country with the resources of the United States has many other advantages, said Andreas Handel, an assistant professor in the department of epidemiology and biostatistics at the University of Georgia’s College of Public Health, in an email sent before the nurse’s diagnosis and flight were reported. “I’m fairly certain that surveillance and containment capacities in the U.S., Europe and other countries with more resources and better developed health systems will make any large-scale spread of Ebola very unlikely,” Handel said.

Senegal never got more than three known cases. Nigeria was tougher, experiencing a wider outbreak. WHO applauded Nigeria’s “world-class epidemiological detective work” in tracking infections, after the initial one spread to secondary and even tertiary contacts. Nigerian health officials made nearly 20,000 in-person visits to monitor contacts, and pre-existing investment in Nigerian health infrastructure by the Centers for Disease Control and Prevention and the Bill & Melinda Gates Foundation also helped, The New York Times reported.

“It is amazing to me that they were able to contain the outbreak as quickly as they did,” Benjamin Neuman, a virologist at the University of Reading in the United Kingdom, said in an email.

It’s difficult to tease out cause and effect in Nigeria’s success. Did detecting the disease quickly give it a leg up, or was its early detection a function of its high-functioning health-care system, which helped stem the spread of the disease? “The lag between the start of an outbreak and the number of people infected before an outbreak is noticed as occurring generally depends on the quality of the health and surveillance system,” Handel said.