EDINBURGH, UK (CBS) – Up all night counting sheep? A new study has a tasty suggestion: Try some chocolate.

Researchers at The University of Edinburgh in Scotland found that magnesium can help your body regulate its internal clock, so you can sleep better at night and feel more awake during the day.

READ MORE: Missing Man's Body Recovered From Taunton River In Somerset

Dark chocolate, as well as leafy greens like spinach and kale, are rich in magnesium.

READ MORE: Framingham Man Seriously Injured In New Hampshire Rollover UTV Crash

The scientists said magnesium “has an unexpected role in helping living things remain adapted to the rhythms of night and day.”

The mineral is also found in nuts, seeds, fish, beans and dried fruit.

MORE NEWS: Rep. Stephen Lynch: 'We Have To Get To An Agreement' On Stalled Infrastructure Bill

Previous studies have shown that chocolate may have health benefits for both the heart and brain.