A Kentucky man who acknowledged threatening President Barack Obama in a poem has been sentenced to nearly three years in prison.

Johnny Logan Spencer apologized for writing the poem, which described a fatal sniper shooting of the president.

The 28-year-old said in federal court in Louisville on Monday that he was upset over his mother’s death and had fallen in with a white supremacist group that had helped him kick a drug habit.

U.S. District Judge Joseph H. McKinley Jr. called Spencer’s writing of the poem an extremely dangerous thing. Spencer will be on supervised release for three years after he completes the 33-month sentence.

The poem, titled “The Sniper,” was posted on a website in 2007 and again in 2009 after Obama took office.

HP