Most of us have learned the hard way that there’s a certain technique to pouring our beer without making it overflow and ruin everything. You have to strategically tilt the glass as you pour to prevent a massive buildup of foam. Why? Because beer chemistry.

The foam is due to all of the carbon dioxide in the beer bottle or can. As SciShow explains, when you crack open a beer, that satisfying kychuk sound indicates some carbon dioxide has escaped, but most of it is still inside the can. As you waterfall the beer, tilting the glass helps you avoid trapped air pockets called nucleation sites that would help the rest of the carbon dioxide escape. When the escaped gas combines with proteins from the beer’s grains, you get the bubbly foam, otherwise known as head.