Do you chide yourself for wasting time in front of the television, watching Law and Order reruns? Good news: It turns out that, without realizing it, you may have been doing something genuinely valuable.

You’ve been replenishing your depleted self-control.

That’s the conclusion of a new study by psychologist Jaye Derrick of the University of Buffalo’s Research Institute on Addictions. She reports immersion in a “familiar fictional world” can help us recover the all-important ability to resist temptation.

Staring at Seinfeld, it turns out, can be part of your self-help regimen.

The research grows out of the theory, espoused by prominent research psychologists including Roy Baumeister and Kathleen Voss, that impulse control is a limited resource. Numerous experiments have shown that people who are forced to exercise self-discipline are more likely to give into temptation later on. Avoiding those brownies sitting on the kitchen table at work all day makes it more likely you’ll eat something caloric that evening.

So how do you replenish self-control? Getting into a positive mood seems to be one key, and while that can be done through self-affirmation, for most people it involves interacting with friends and family. But of course, dealing with significant others can be stressful, depending upon the circumstances. Bickering with your spouse hardly raises one’s spirits.

Enter your virtual families and friends—the colorful characters of Sex and the City, or, well, Friends. Derrick refers to our relationships with them as “social surrogacy,” and shows that spending some quality time with them can do us good.

Writing in the journal Social Psychological and Personality Science, she describes a study featuring 205 participants (average age 33). Half were asked to write a short essay (10 to 12 sentences) describing a recent trip.

The others were given the same assignment—except that they were not permitted to use the letters a or i. The banishment of these common letters meant they had to exert high levels of self-control in the process of writing. Afterwards, all the participants either wrote about a favorite television program, or listed the items in their apartment.

Finally, everyone took a test in which they were given three words and asked to generate a fourth that was related to the trio. (Example: For the words “sea,” “home” and “stomach,” the correct response was “sick.”) This required considerable concentration, and was thus a measure of self-control.

Even though they were more tired, those forced to avoid words with “a” or “i” wrote more about the TV show than those who had completed the easy version of the assignment. The effort they expended apparently made them more eager to describe their favorite fictional world. This same effect was not found for the list of items in one’s apartment, which were of roughly the same length for people in the two groups.

The most telling results, however, were those on the final test. Among the participants who listed their apartment contents, those who had the stressful essay-writing assignment had fewer correct answers than those who had the effortless experience. They also reported being in a much fouler mood.

However, for those who had written about their favorite television show, the scores were virtually identical—as were the participants’ reported moods. Thinking about and describing the pleasing program put them in a better state of mind, and restored their self-control to its previous level.

A second experiment, in which 86 people kept a daily diary of their thoughts, feelings and activities, confirmed that “people selectively seek familiar fictional worlds” to restore self-control, Derrick writes.

While she concedes that spending time in front of the tube may not be the optimal way to rejuvenate ourselves—physical exercise, she notes, can also lift mood—her results suggests it's unfair to think of television viewing as a waste of time.

“Media use can have unexpected psychological benefits,” she concludes. “Television, movies and books can be more than leisure activities; in some cases, they fulfill needs, like restoring self-control, that people are reluctant or unable to fulfill through other means.”

So if feel your self-control running low, reach for the remote rather than the refrigerator door. After an episode of 30 Rock, you may no longer crave that Rocky Road.