The Montana Supreme Court has overturned the sentence in a Whitefish arson case, finding the judge was wrong not to allow the defendant to withdraw his "no contest" plea when the judge didn't follow the plea agreement.

The court on Tuesday sent the case of 35-year-old James Wallace Langley to District Court in Flathead County for another sentencing hearing.

The justices said the judge can accept the plea agreement and re-sentence Langley or give him the opportunity to withdraw his plea.

Under the non-binding plea agreement, prosecutors recommended a six-year deferred sentence for setting fire to the siding of his ex-girlfriend's house in October 2013. District Judge Robert Allison didn't feel that was enough time for "an act calculated to injure or kill."

He sentenced Langley to five years with the Department of Corrections.