The man who crashed into a church van, killing two people off Chapman Highway in 2012, got bad advice in a plea agreement that was supposed to ensure he received credit for serving a state sentence at the same time as a federal sentence, an appeals court has ruled.

"This case should serve as a cautionary tale for any prosecutor, defense attorney or trial court who attempts to negotiate or accept a guilty plea involving concurrent state and federal sentencing," Tennessee Court of Criminal Appeals Judge Timothy Easter wrote in a decision filed Oct. 6.

Tyler James Schaeffer, 26, agreed to a plea deal in September 2014 in Sevier County Circuit Court for multiple counts including two counts of vehicular homicide.

He killed two people when he collided head-on with a church van on Chapman Highway in Sevier County.

Testing showed traces of several drugs. Authorities said he was high on rock salts. The crash occurred as he was texting about a drug deal, records show.

Schaeffer agreed to plead guilty in state court so long as his 40-year negotiated state term ended up being served concurrent with a federal sentence of 100 years that he received after trial. Federal prosecutors won convictions against Schaeffer on robbery, drug and gun charges for a series of crimes that occurred before the fatal crash.

Schaeffer observed later that he didn't want to have to serve the state sentence consecutive to the federal term.

His court-appointed public defender, the Sevier County district attorney's office and Judge Rex Henry Ogle all understood that the plea deal centered on the two terms being served concurrent to each other.

However, as the Court of Criminal Appeals panel found this month, there's no way to ensure the federal system will go along with such a deal.

Federal authorities can make an inmate serve a federal sentence at their discretion. In Schaeffer's case, the system hadn't yet accepted him to begin serving his federal time, so he was serving his state time.

Schaeffer sought to overturn the state deal, arguing his defense attorney signed him up for a plea that couldn't be honored. His state term is set to end in 2051.

MORE: DA: Schaeffer was high on bath salts during crash

State appellate court judges agreed.

"It is abundantly clear that (Schaeffer), trial counsel, the district attorney general, and the trial court had the intent to run (Schaeffer's) state sentence concurrently with his federal sentence," the court wrote, reviewing the case as a post-conviction relief decision.

"However, neither trial counsel, the district attorney nor the trial court possessed the power to impose concurrent sentencing on the federal government."

What the public defender agreed to was essentially "an empty promise," the court found.

"(Schaeffer's) plight is that he could end up serving a consecutive sentence because there is no way to ensure that he will not be taken into federal custody and required to serve his entire federal sentence upon the completion of his state sentence."

In 2000, the appellate court noted, it addressed a very similar car in which a man thought he'd get credit for his state sentence while serving a federal term when in fact the feds declined to take him into custody.

Because Schaeffer, now being held at the Morgan County Correctional Complex, got bad advice, his Sevier County case must be revisited.

Easter suggested the defense and prosecution try to work it out with federal authorities so that Schaeffer can begin serving his federal sentence.

"If specific performance is an impossibility, the parties should enter into new plea negotiations taking into account the intentions of the failed plea agreement," the court wrote. "The agreement failed through no fault of the petitioner. In our view, plea negotiations and sentencing should take into account the time the petitioner has served in prison and in the county jail."

If the problem can't be resolved, then Schaeffer should be allowed to withdraw his guilty pleas so that he can face a state trial, the court wrote.

The van from Cedar Grove Baptist Church was returning from a weekend retreat in Gatlinburg at the time of the crash.

The fiery collision killed Courtney Kaliszewski,16, and youth leader Jeff Trussell, 45, and injured 10 other youth group members.