When you look at a fossilized skull from the mighty Tyrannosaurus rex there are a few things you’ll immediately notice. For starters, it’s huge compared to the rest of its body, with almost cartoonish proportions. It’s also packed with massive, dagger-like teeth that could crush just about anything and, wait, what are those big holes for?

For years, the prevailing theory of why the T. rex had those large gaps in its skull was related to its complex jaw muscles. It was believed that dense muscles took up this space and aided the animal by providing an even more forceful bite. Now, a new study published in The Anatomical Record suggests that the holes had an altogether different purpose, and it was related to heat management.

For the study, researchers from the University of Missouri, Ohio University, and the University of Florida examined one of the few remaining “modern dinosaurs” still around today: the alligator. Using thermal imaging cameras to reveal how body temperature is regulated in the skull of the creatures, noting that gaps in the alligators’ skulls are great at managing body heat.

“We noticed when it was cooler and the alligators are trying to warm up, our thermal imaging showed big hot spots in these holes in the roof of their skull, indicating a rise in temperature,” Ken Vliet of the University of Florida said in a statement. “Yet, later in the day when it’s warmer, the holes appear dark, like they were turned off to keep cool. This is consistent with prior evidence that alligators have a cross-current circulatory system—or an internal thermostat, so to speak.”

The team believes that the same was likely true for ancient creatures like the T. rex. Blood vessels filling those gaps would have been an excellent tool for cooling down, giving the dinosaur a sort of automatic “air conditioning.”