The trip down the family planning aisle can be an anxious or exciting one as you pick up several pregnancy tests to answer the inevitable question: Are you pregnant? You go home, squat above the toilet seat, and pee on the stick to wait a few long agonizing minutes for the test results. But how exactly does this piece of plastic deliver potentially life-changing results with a high rate of accuracy?

In the TED-Ed video lesson, “How do pregnancy tests work?” Tien Nguyen explains how each modern pregnancy test is able to tell if you’re pregnant within minutes. The concept of the modern pregnancy test started in 1963 when a small study reproduced the ancient Egyptian pregnancy test, where women would urinate on wheat and barley seeds and wait to see if they sprouted. If wheat sprouted faster, they believed it was a girl, but if barley, a boy. The 1963 study was able to predict pregnancy with a 70 percent accuracy rate, although it can’t reliably tell the sex of the baby.

Although many home pregnancy tests claim to be accurate as early as the first day of a missed period or even before, says the Mayo Clinic, it’s best to wait until one week after a missed period. OTC pregnancy tests are all designed to do one thing, detect a hormone called human chorionic gonadotropin (HCG), which is produced in the earliest stages of pregnancy and tells the body not to shed the inner lining of the uterus that month. The hormone enters the bloodstream and urine when it begins production in the placenta, and increases rapidly every two to three days.

The over-the-counter (OTC) pregnancy test begins when urine is applied to the exposed end of the strip as the fluid travels up the absorbent fibers that will cross three separate zones. The first zone, the reaction zone, is where the y-shaped proteins called antibodies — they contain a handy enzyme with the ability to turn on dye molecules — will latch onto any HCG.

The urine then picks up all the AB1 enzymes and carries them to the test zone, where the results show up. This type of test is known as the sandwich assay. If HCG is present, it gets sandwiched between the AB1 enzyme and AB2 and sticks to the test zone, allowing the attached dye-activating enzyme to create a visible pattern. If there’s no HCG, the wave of urine and enzymes just passes on by.

Lastly, the control zone confirms whether the test is working properly. Now, whether the AB1 enzymes never saw HCG, or there are extras because zone 1 is overstocked with them, all the unbound AB1 enzymes picked up in zone 1 should end up here and activate more dye. So if no pattern appears, this indicates the test was faulty.

The tests are reliable but they’re not fail-proof. The possibility of false negatives and false positives occur under several conditions. Concentrations of HCG that aren’t high enough for detection after implantation can mean it’s too early to tell. Also, beverages can dilute the urine sample, hence why it’s best to take a test first thing in the morning. Meanwhile, other sources of HCG like IVF injections, ectopic pregnancies, or certain cancers like uterine cancer or testicular can lead to false positives.

At-home pregnancy tests are just like a science experiment many women conduct within the confines of their bathroom. The only difference is the hypothesis and the results each woman hopes to get.