Some pills are better for people who have trouble falling asleep, while others should be prescribed for people who wake up throughout the night, reports Health.com.

The difference in recommendations is largely because some drugs last longer in the body than others, says lead author Michael J. Sateia, MD, Professor Emeritus of psychiatry and sleep medicine at The Geisel School of Medicine at Dartmouth. “It’s a reminder to clinicians that it’s important to choose an agent that has an appropriate duration of action for the particular type of insomnia you’re treating,” he says.