That’s despite the fact that the gold standard for treating sleep disturbances, recommended by the National Institutes of Health and the American Academy of Sleep Medicine, is Cognitive Behavioral Therapy for Insomnia (CBTI). CBTI, which focuses on changing behaviors that can contribute to poor sleep, has been shown to work long-term while sleeping medications tend to lose effectiveness after a few weeks (sleep medications may, however, be prescribed initially along with CBTI).

So why are pills the most common solution? Convenience, for one. Even if you’re willing to seek out a sleep experts who is qualified to give CBTI, you may not find one near you. Despite the epidemic of sleep disorders and their impact on health, there are only a few hundred sleep experts in the whole country.

Doctors may also be unaware of the therapy. “I do not think many doctors know about CBTI,” says Rachel Manber, professor of psychiatry and behavorial sciences at Stanford University Medical Center. “Some provide sleep hygiene recommendations. However, like dental hygiene, sleep hygiene is best thought of as preventive rather than treatment.” These include sleeping in a dark room, sticking to regular bed times, and avoiding caffeine and exercise before bedtime.

If you did find your way to a sleep clinic expert, you would have an extensive interview about your medical history and sleep problems and fill out a detailed sleep diary for two weeks, then return for treatment. If that information points to a medical problem like sleep apnea, then you would have to spend at least one night sleeping in a lab, hooked up to a multitude of sensors that monitor your respiration, heart rate, and sleep level measured by an EEG . Then, after these recordings help to diagnose your sleep issues, you would start treatments with a therapist to develop habits that condition you to sleep better at bedtime and improve your quality of sleep, by helping you to turn down stressful thoughts and avoid things around you that interfere with good sleep.

Most CBTI treatments take four to six weeks to be fully effective, which helps to explain why it pales in comparison to the immediate, if not long-lasting, benefit of sleeping pills. But now, Israeli scientists have come up with a way to potentially streamline the therapy for some by bypassing the sleep lab and delivering the treatment via smartphone.

SleepRate is an app that helps people who can’t or won’t go to a sleep clinic to generate, in DIY fashion, the same kind of information that all the monitors do to help sleep experts design the right behavioral therapy for patients. Anda Baharav, SleepRate’s founder and a former researcher at the Medical Physics Department at Tel Aviv University says this product can detect sleep disturbances by mathematically defining the connection between sleep, heart rate and respiration. They have combined their diagnostic method with a smartphone adaptation of a Stanford University proprietary CBTI treatment to bring CBTI to more people with sleep disorders. Anyone with an iPhone or certain other smartphones can download the app kit for $99, which comes with the sleep plan and a heart-rate monitor worn across the chest.

Here’s how it works. You sleep in your own bed for five nights with the chest belt and app on, and you also record how you feel subjectively about your sleep and alertness before you start the program, and then again every evening and morning for the five days of the assessment. The app keeps track of all the information in a sleep diary, and provides the results from the previous night’s sleep in an easy-to-read graphic. which the user can see and learn how long it takes to reach stable sleep, how many times you wake during the night, the sequence of your sleep stages throughout the night and how much quality sleep you get. Your phone’s microphone will also record noises around you and identify which ones wake you up. “If you’re used to living in New York City, for example,” Baharav says, “the traffic and sirens may not wake you, but your fridge banging on at 4 a.m. might.” So your sleep plan might include a service call from your appliance company—or a new fridge.

After the five-night assessment, you get a personalized sleep plan based on your particular sleep issues. The plan guides users about when to go to bed and when to wake up, suggests exercises to help them unwind and forget about the day’s worries, and even outlines how to spend buffer times, or the one to two hours before bed when it helps to do routine, unexciting things such as taking a bath, listening to music, or reading (but no thrillers). Based on the information you entered, for example, your smartphone screen will alert you about when to start your buffer time activity, with something like a cartoon of someone sitting quietly on a sofa with the instruction: Start Buffer Zone.

The suggestions are offered sequentially over four to six weeks to give you time to learn the new behaviors. If you don’t reach a goal, you try again, and when you achieve your goal, such as getting out of bed at the same time for several days in a row, the program provides a new target. You can also pull up your sleep data at any time to see patterns and trends. And the app reminds you what not to do as well: No! Don’t take a nap now.

While there are other such user-friendly CBTI kits available, Shelby Harris, director of the Behavioral Sleep Medicine Program, Sleep-Wake Disorders Center at Montefiore Medical Center in New York, says SleepRate is “more comprehensive since it also takes into account medical causes for insomnia.” Because there is a shortage of qualified CBTI practitioners, she sees such apps as viable and welcome first-line efforts for helping people with insomnia. If the programs don’t help, she says, then patients can see a sleep specialist.

And what about people who don’t have a diagnosable sleep disorder but are simply sleep deprived? Could such a program, for example, help parents of babies and young children to find more good quality sleep? Baharav says that’s coming soon. Stay tuned.