From left, Taraji P. Henson, Octavia Spencer, and Janelle Monáe in Hidden Figures (Hopper Stone)

When we first meet the main protagonists, they are stranded by the road in 1960s Hampton, Virginia, due to mechanical problems with their car. A police officer pulls up. Segregation is still the law of the land here, and the three black women—Katherine Johnson (Taraji P. Henson), Mary Jackson (Janelle Monáe), and Dorothy Vaughan (Octavia Spencer)—are nervous about how the white police officer will treat them, and, indeed, their initial interactions hint at possible abuses of power to come.

But then the cop learns that all three women work as mathematicians for NASA, at a time when the United States and the Soviet Union are locked in a battle for domination of space. He expresses concern about what will happen if the Soviets win. Dorothy fixes the car, but the policeman insists on providing them with a personal escort, at high speed and sirens blaring, so they can get to their base on time.

It’s a remarkable sequence that establishes the women’s traits: Dorothy is practical; Mary is fiery and temperamental, nearly getting them into trouble by running her mouth; and Katherine is the dreamer. But it also suggests that the racial divide of that time was not absolutely insurmountable. All it took was a threat serious enough to motivate everyone, regardless of skin color and gender, to start looking past differences.

Based on real-life trail-blazing women, the trio work as “computers,” the term for NASA’s flesh-and-blood female mathematicians. However, despite their considerable abilities, they meet resistance as a result of institutionalized racism. Mary, who assists on the Project Mercury capsule’s heat shield, entertains ambitions of becoming an engineer herself. But that would require night classes at a segregated high school. Similarly, Dorothy is consistently passed over for a supervisor’s title, even though she manages the African American staff and essentially does the same job as the white women’s supervisor (Kirsten Dunst).

As for Katherine, she lands a role assisting the flight research team, thanks to her knowledge of analytical geometry. On her very first day, she serves herself from the communal coffee pot. By the second, there is a separate pot labeled “Colored,” which no one bothers to either fill or plug in.

Allison Schroeder and director Theodore Melfi’s screenplay uses the Soviet menace to argue against denying the three women of their successes. After all, each one’s work could tip the Cold War in the U.S.’s favor, and, as such, racism arguably puts the very future of the American way in jeopardy. The discrimination they face may not be as visceral as in a film like Selma, but it is nevertheless omnipresent and demoralizing: In a development that makes Katherine especially sympathetic, she must walk half a mile every time she needs to relieve herself, as there are no “colored” restrooms in the flight researchers’ building. Her lengthy disappearances culminate with a haranguing by her boss, Al Harrison (Kevin Costner), who is oblivious to her predicament.

By and large, white people seem to have nothing personal against the women but are simply upholding the separation that has long been in place. Yet the film argues that even if they are not actively perpetrating racism, their obliviousness can be just as harmful. Despite the previously mentioned incidents, the film is not at all soul-crushing, lightened throughout by scenes of the women’s personal lives. An especially interesting detail is that Katherine, Mary, and Dorothy each qualifies as an excellent mother, but exactly how they go about inspiring their children differs.

Hidden Figures’ greatest asset is its marquee actresses, especially Henson and Spencer. As Johnson, considered a pioneer in the fields of computing and space science, Henson plays someone decidedly more reserved than her best-known roles (including Loretha “Cookie” Lyon in the TV series Empire). However, she does get to cut loose with a furiously righteous speech. Meanwhile, Spencer’s character knows when to resort to courtesy versus saying exactly what’s on her mind, leading to delightfully humorous moments.

Other effective casting additions include Moonlight’s Mahershala Ali as a love interest for Katherine and Glen Powell as the late astronaut John Glenn, whose core of decency leads to our rooting for him in the face of plainly dangerous flight scenarios. (For those interested, the recent documentary Fight for Space also touches on this important chapter in the history of NASA.)

Ironically, the release of Hidden Figures takes place just weeks before the ushering in of a presidential regime with a less-than-progressive reputation toward minorities. But as uncertain as things may look right now, the film reminds us of exactly how far the United States has come since the days of legal segregation and of our capacity to overcome what forces divide us. If for no other reason than that, it’s the triumphant historical drama we need right now.