Starting your day off with a cup of coffee is a nearly universal American experience. A piping hot cup of caffeinated crude can help you shake off the cobwebs of a long (or short) night’s sleep and serve as an important part of your morning ritual, but for those that have stood 24 hour posts or been in dangerous situations where staying awake and alert was integral for survival, coffee begins to assume a different role in your brain. In the field, coffee isn’t a relaxing way to start your day, it’s one of a slew of tools you use to keep your eyes open and brain functioning until the opportunity for sleep presents itself.

My Marines and I would sometimes skip the water all together, pouring the Folgers Choice instant coffee from our MREs directly into the space between our teeth and lips like chewing tobacco. Admittedly, chew did a better job of keeping you up, but the drugs that help keep you conscious all come with a physical price: too much nicotine would make you feel terrible, too much caffeine could do the same, and the more you used either, the less effective they became as a tool in the long run.

Caffeine intake, it will come as no surprise, is more than just a cultural touchstone for service members, for most of us, it was an integral part of the job — and it was with that in mind that the U.S. Army recently set about spending tax payer’s dollars on finding ways to maximize the beneficial effect of coffee while minimizing an individual’s required intake. In short, the Army wants each soldier to get the most bang for their (mg of caffeine) buck, and according to their findings, that all has to do with the timing of consumption.

“We developed algorithms that work together, and they essentially allow us to determine, at the individual level, when and how much the individual should take caffeine to achieve peak performance at the desired time, for the desired duration,” said study senior author Jaques Reifman, director of the DoD Biotechnology High Performance Computing Software Applications Institute at the U.S. Army Medical Research and Materiel Command in Fort Detrick, Maryland.

Reifman then volunteered a civilian example of what their algorithm aims to do: imagine you’re a student that’s spent a week cramming for an important exam. You’ve been up all night hitting the books each night, then back in your regular classes during the day — by the time your exam rolls around on Friday, you’re bound to be exhausted. Their algorithm would help you to determine when exactly to drink your pre-exam coffee “so you are as alert as possible during the exam.”

The secret to ensuring you’re at your best when you need to be is all in the details, researchers determined. Amount of sleep, amount of caffeine taken in, and the time one takes it all combine with personal biology to create an alertness curve as the caffeine’s effects kick in, top out, and wane. Using a smartphone application (which has been released to the public) the algorithm can give you rough estimates of when you’ll be at your most alert, but it becomes more effective the longer you provide it with data points. Currently, the publicly available app won’t tell you when to drink your coffee to get your best performance, but it can predict your alertness levels at given times based on the data you provide.

How effective is this new form of timed caffeine dosing? It varies, but the Army’s team of researchers claim performance improvements ranging from 16 to 64 percent when doing the sort of tasks tested under normal conditions. More importantly, those numbers were coupled with between a 17 and 65 percent reduction in caffeine consumed — meaning soldiers were more alert and capable while requiring less caffeine.

The study into how this algorithm can help keep America’s war fighters alert on the battlefield is ongoing (with caffeine laden soldiers continuing to serve as this program’s guinea pig for some time to come) but you can find the smart phone application here to try it out for yourself, or go to the website to get “Average Joe” estimates about your own coffee intake.