Back in the 1st century CE, you could bless yourself—for a price.

Fast forward 2000 years and, yes, you can get an iPad from a vending machine. Other items easily procured with the dispense of a few coins include beverages, snacks, shoes, and even live crabs. However, the first vending machine—which sold holy water—is right up there with unconventional purchases.

According to Smithsonian.com, the first vending machine was invented by Hero of Alexandria, also known as Hero. (You can also thank him for creating the syringe and one of the first steam engines, among many other inventions.)

In our technological age, it’s hard to imagine how a vending machine could have existed so long ago. Smithsonian.com explains how it worked: “A person puts a coin in a slot at the top of a box. The coin hits a metal lever, like a balance beam. On the other end of the beam is a string tied to a plug that stops a container of liquid. As the beam tilts from the weight of the coin, the string lifts the plug and dispenses the desired drink until the coin drops off the beam.”

The Epoch Times compares the process to that of flushing a toilet, noting the similarities between the specific amount of holy water dispensed into the vessel and the amount of water that fills a toilet bowl after it’s flushed. Hero himself described the process in the book The Pneumatics of Hero of Alexandria, noting the price for one allocation of holy water: a five-drachms coin. The book also includes a diagrammed illustration of his invention. Needless to say, it’s very different from the brightly lit vending machines that populate airports, malls, and so many other places today.

One of the most fascinating aspects of this invention, aside from its mechanism, is the reason behind creating it. John Humphrey, a professor of Greek and Roman studies at the University of Calgary, told Smithsonian.com the machine was devised because people were taking more holy water than they were paying for.

The concept of the vending machine didn’t take off for many, many more centuries. Even so, early versions didn't have the technology of Hero’s invention. A snuff and tobacco vending machine introduced around 1615 opened automatically after money was inserted, but displayed its entire contents, leaving the customer to choose their tobacco product manually and close the machines themselves. For obvious reasons, these machines came to be known as Honor Boxes.

The first modern, commercial vending machines didn’t surface until around the Industrial Revolution when, in 1883, Percival Everett designed a vending machine that provided postcards. However, Hero’s mechanisms were used in modern vending machines until they became powered by electricity.