Researchers are using smart phones and hand-held computers to figure out why some people quit smoking the first time they try, while others are unsuccessful even after many attempts.

Scientists at Penn State and the University of Pittsburgh collected data from smokers through mobile devices, to determine how smokers’ nicotine dependence and negative emotional states influence their urge to smoke while they try to quit.

They found people who successfully quit during the four-week study had a weaker association between their urge to smoke and their ability to quit, Medical News Today reports. Smokers who were unable to quit did not demonstrate any association between their urge to smoke and their self-confidence, the study found.

“One thing that really stood out among the relapsers is how their urge to smoke just never dropped, in contrast to those who were successful in quitting for a month—their urge dropped quickly and systematically—almost immediately upon quitting. That was surprising to see,” researcher Stephanie Lanza said in a news release.

The study included 304 smokers who had smoked an average of more than a pack a day for 23 years. Five times throughout the day, at random times, mobile devices prompted them to answer questions about their emotional state, their urge to smoke and if they were smoking. Participants rated their urge to smoke at that moment on a scale of zero to 10.

Forty participants quit smoking in the first day, but then relapsed. Another 207 participants quit and remained tobacco-free for at least two weeks (if they smoked less than five cigarettes a day, they were considered successful quitters). The 57 remaining participants could not quit for even one day.

The results appear in the journal Prevention Science.