Music makes life better in so many ways. It elevates mood, reduces stress and eases pain. Music is heart-healthy, because it can lower blood pressure, reduce heart rate and decrease stress hormones in the blood. It also connects us with others and enhances social bonds. Music can even improve workout endurance and increase our enjoyment of challenging activities.

The fact that music can make a difficult task more tolerable may be why students often choose to listen to it while doing their homework or studying for exams. But is listening to music the smart choice for students who want to optimize their learning?

A new study by Manuel Gonzalez of Baruch College and John Aiello of Rutgers University suggests that for some students, listening to music is indeed a wise strategy, but for others, it is not. The effect of music on cognitive functioning appears not to be “one-size-fits-all” but to instead depend, in part, on your personality—specifically, on your need for external stimulation. People with a high requirement for such stimulation tend to get bored easily and to seek out external input. Those individuals often do worse, paradoxically, when listening to music while engaging in a mental task. People with a low need for external stimulation, on the other hand, tend to improve their mental performance with music.

But other factors play a role as well. Gonzalez and Aiello took a fairly sophisticated approach to understanding the influence of music on intellectual performance, assessing not only listener personality but also manipulating the difficulty of the task and the complexity of the music. Whether students experience a perk or a penalty from music depends on the interplay of the personality of the learner, the mental task, and the music.

In the study, participants first completed the Boredom Proneness Scale, which is a personality test used to determine need for external stimulation. They then engaged in an easy cognitive task (searching for the letter A in lists of words) and a more challenging one (remembering word pairs). To control for practice and fatigue effects, half of the subjects completed the easy task first, while the other half completed the challenging one first. Participants finished both tasks under one of three sound conditions: (a) no music, (b) simple music or (c) complex music. All of the music was instrumental, and music complexity was manipulated by varying the number of instruments involved in the piece. Simple music included piano, strings and synthesizer, while complex music added drums and bass to the simple piece.

The data suggest that your decision to turn music on (or off) while studying should depend on your personality. For those with a high need of external stimulation, listening to music while learning is not wise, especially if the task is hard and/or the music is complex. On the simple task of finding A’s, such subjects’ scores for the music condition were the same (for simple music) or significantly worse (for complex music) than those for the silent condition. On the complex task of learning word pairs, their performance was worse whenever music was played, regardless of whether it was simple or complex.

For those with a low need of external stimulation, however, listening to music is generally the optimal choice. On the simple task of findings A’s, such participants’ scores for the music condition were the same (for simple music) or dramatically better (for complex music) than those for the silent condition. On the complex task of learning word pairs, the participants showed a small but reliable benefit with both simple and complex music, relative to silence.

The results suggest that there are substantial individual differences in the impact of music on cognitive function, and thus recommendations regarding its presence in the classroom, study hall or work environment may need to be personalized. Students who are easily bored and who seek out stimulation should be wary of adding music to the mix, especially complex music that may capture attention and consume critical cognitive resources that are needed for successful task completion. On the other hand, students with a low need for stimulation may benefit significantly from the presence of music, especially when completing simple, mundane tasks.

Before students decide to slip in their earbuds, though, they should carefully consider both their musical selection and the nature of the task. All of the music used in the present study was instrumental, and lyrical music will likely be more complex. Complexity appears to increase arousal, and the Yerkes-Dodson law suggests that a moderate level of arousal produces optimal performance. When there is too little or too much arousal, performance drops. Thus, the benefits of music for those with a low need for external stimulation that were observed here could diminish or even disappear with the added complexity of lyrics.

Similarly, increases in the complexity of a cognitive task might also reduce or eliminate the benefit of music. Although the “complex” task used in this study (learning word pairs) was only moderately challenging, the increase in complexity, relative to the simple task, was enough to reduce music’s positive effect. With a highly challenging cognitive task (e.g., text comprehension or exam preparation), even those with a low need for external stimulation may fail to show such an effect with music.

With the right (low-need-for-stimulation) personality, the right (instrumental) music and the right (low-to-moderately-difficult) task, the presence of music may significantly improve cognitive functioning. Given the many other physical, emotional and psychological benefits of music, that subscription to Spotify just might pay for itself!