The quest for a quick pick-me-up is a lot more complex than you may realize.

The Science Channel has put out this entertaining clip which explains just how vending machines work. We've all used them, whether we need some sugar to help us make it through an afternoon on the job or killing time in a hospital waiting room. But did you ever really stop to think what makes these giant roped-off houses of salted and sugary treats operate?

Specifically, the clip addresses how vending machines know to discard fake coins (sensors and electromagnets are involved), which should finally dash your dreams of paying for a Kit Kat with nothing but tokens from Chuck E. Cheese's. It also sheds light on how machines figure out how much change to give back, as well as how the food you want makes it from the machine into your hands. Spoiler alert: there are infrared beams at play, which makes your bag of Frito's escaping the machine almost as impressive as you breaking into the U.S. Mint.

Of course, vending machines don't always cooperate and your food can get jammed. People, however, usually get what they want, so the next time you put in a jumble of nickels, dimes and quarters to get some Chuckles, a Twix bar or a bag of M&Ms, just remember the whole process you've set into motion.

More From 99.9 KTDY