There’s a good reason why some of the songs on Neil Young’s new record may sound a bit downbeat.

He recorded it in the days before he underwent surgery earlier this year for a brain aneurysm.

The legendary rocker tells Time magazine he wrote the first song on “Prairie Wind” on his way from New York to a Nashville studio after getting the disturbing news from his doctor in March.

“Then I went back up to New York on Monday for a pre-surgery thing, flew back to Nashville, wrote and recorded [tracks] four, five, six, seven, eight and most of nine and 10,” said Young, 59. “And then I got admitted, and they put me under.”