You’ve heard it countless times: you need to get eight hours of sleep every night… or so just about everyone says.

But what about those times when you do catch those eight hours — and sometimes even more! — but you wake up completely exhausted and utterly perplexed? Did you somehow sit awake staring at the wall for the whole night and totally block it out?

The truth is that — there’s no such thing as the magical eight hours, despite what you’ve been led to believe.

Because there are so many factors at play, your sleep needs are unique, and they vary from one person to another just as much as optimal diet and exercise regimens do. So how do you find your own secret recipe to catch a perfect night of rest?

That’s where science and technology come in.

Physicians and psychiatrists have been researching and monitoring the science of sleep for hundreds of years to try and demystify what happens when you nod off, but it wasn’t until 1929 when a major breakthrough in understanding our nocturnal habits came in the form of a device called the electroencephalograph (EEG), which records brain waves.

Monitoring and recording brain waves opened up a realm of scientific ability to understand what our brains are doing during sleep and wakefulness. In 1937, Alfred Loomis, E. Newton Harvey and Garret Hobart used EEG traces to identify five distinct stages of sleep, which has since lead to the discovery of REM cycles.

Unfortunately, this kind of technology and the ability to understand its outputs has not been accessible to everyday folks like you and me — until now.

Chances are, you own a nifty little gadget called a smartphone, and let me tell you, they don’t call them ‘smart’ for nothing! These days, you can use an app on your phone much in the same way as an EEG, except the app uses movement to measure your sleep with a type of research technology called actigraphy. This allows phone users to measure their sleep in their natural bedroom settings, instead of going to a lab and getting wired up to all kinds of sensors that look like something from a science fiction movie.

So, the next question that comes to mind is how accurate are these sleep trackers? To answer this question we need to understand how sleep trackers work. These wearable devices track sleep by movement, as do apps like Sleep Cycle and Sleep as Android, either by detecting when your bed moves or by listening for sounds during the night. Movement is not the same thing as sleep, but sleep labs do monitor movement—along with other body functions, like breathing, eye movement, and brain activities. So, even though the wearable trackers currently available might not give you the complete picture, they can help improve it.

Simply being aware of our true sleep quality can help us improve it, especially since it can highlight which habits have negative or positive consequences. We can use sleep tracking as a tool to answer a range of questions: How many hours do I sleep each night? How long does it take for me to fall asleep? Am I getting enough deep sleep, light sleep and REM? Getting to the bottom of these issues helps us determine exactly when our good nights turn bad, and we can even draw connections between the food we eat, our daily activities, and the quality of our shuteye.