
544 N.W.2d 453 (1996)
STATE of Iowa, Appellee,
v.
Stephen Robert DAVIS, Appellant.
No. 94-2063.
Supreme Court of Iowa.
February 14, 1996.
*454 Linda Del Gallo, State Appellate Defender, and Andi S. Lipman, Assistant State Appellate Defender, for appellant.
Thomas J. Miller, Attorney General, Susan M. Crawford, Assistant Attorney General, Paul L. Martin, County Attorney, and Kathleen Selzler, Assistant County Attorney, for appellee.
Considered by McGIVERIN, C.J., and LARSON, CARTER, LAVORATO, and SNELL, JJ.
LAVORATO, Justice.
The defendant, Stephen Robert Davis, pleaded guilty to third-degree burglary, a felony. The district court sentenced Davis to five years, suspended his sentence, and placed him on probation for two years. The court imposed two conditions of probation. First, Davis was ordered to receive inpatient treatment for substance abuse. Second, following this treatment, Davis was ordered to reside at a residential facility for 180 days or until he received maximum benefits. The district court then ordered Davis to be held in the county jailwhere he was already in custodyuntil space became available at the treatment facility.
Davis appealed from his conviction and sentence, contending the district court lacked authority to impose jail time as a condition of probation. We transferred the case to the court of appeals. The court of appeals agreed with Davis, vacated the sentence imposed, and remanded for resentencing.
We granted the State's application for further review. We now conclude the district court did not impose jail time as a condition of probation. Rather, the district court ordered Davis temporarily held in the county jail pending availability of space for him at the inpatient substance abuse treatment facility. Our review of the statutes leads us to conclude the legislature intended the district court to have such authority. We therefore vacate the court of appeals decision and affirm the district court's judgment of conviction and sentence.
On October 18, 1994, the State charged Davis with burglary in the third degree, a class "D" felony. See Iowa Code §§ 713.1, 713.6A (1993). In substance, the trial information alleged that Davis unlawfully entered *455 an unlocked car with the intent to steal a radio located inside.
Following his arrest on this charge, Davis was released from custody under pretrial supervision. On October 31 Davis was again in custody after having been arrested for three offenses: (1) criminal mischief in the fourth degree, (2) interference with official acts, and (3) being in a tavern as a minor.
Subsequent negotiations between Davis and the State resulted in a written plea agreement. Under the agreement, Davis agreed to plead guilty to the burglary charge. The State agreed to recommend that Davis receive a suspended sentence.
Following Davis' formal plea of guilty, the district court accepted the plea agreement. The court then sentenced Davis to an indeterminate term of imprisonment not to exceed five years, suspended the sentence, and placed Davis on probation to the department of correctional services for two years.
The court imposed two conditions of probation. First, the court ordered Davis to attend an inpatient substance abuse treatment program at Prairie Ridge in Mason City. Second, the court ordered Davis, following treatment, to reside at the BeJe Clark residential facility for 180 days, or until he received maximum benefits.
The court additionally ordered that Davis be held in the Cerro Gordo county jail until space became available for him at the Prairie Ridge facility.
Just before the sentencing, Davis' attorney asked the court to consider releasing Davis to the custody of his parents until he could enter Prairie Ridge. Davis was scheduled to enter the treatment program exactly one week following the sentencing hearing. Because of Davis' poor performance on pretrial release for this offense, the court declined to release Davis to his parents' custody. Instead, the court ordered Davis to remain in the county jail until space became available for him at Prairie Ridge.
Davis argues that the district court erroneously sentenced him to jail time on the felony offense of burglary as a condition of probation. The State counters that the court did not order Davis to be confined in the county jail as a condition of probation. The court  the State saysmerely ordered Davis held in the county jail until he could be transferred to Prairie Ridge to start fulfilling his first probationary condition. The State points to various statutory provisions which, it claims, evidence a legislative intent to grant the district court such authority.
These contentions raise the issue whether the district court had the authority to temporarily confine Davis in the county jail until space for him became available at the treatment facility. If such authority was lacking, the confinement constituted an illegal sentence.
Because Davis challenges the legality of sentence, our review is for errors at law. State v. Morris, 416 N.W.2d 688, 689 (Iowa 1987). We may correct an illegal sentence at any time. State v. Austin, 503 N.W.2d 604, 607 (Iowa 1993).
To support his contention that the court sentenced him to a jail term as a condition of probation, Davis relies heavily on State v. Tensley, 334 N.W.2d 764 (Iowa 1983). Davis' reliance on Tensley misses the mark. In Tensley, the district court imposed a ten-year indeterminate sentence, suspended the sentence, then ordered the defendant to serve 180 days in the county jail as a condition of probation. We held that granting probation and imposing confinement are mutually exclusive, except when expressly authorized by statute. Although we recognized that in certain limited circumstances, statutory authority exists for a split sentence and confinement, we concluded statutory law did not authorize confinement in the county jail as a term of probation. Tensley, 334 N.W.2d at 764-65.
Here, in contrast, the district court did not expressly order Davis to serve time in the county jail as a condition of probation. Rather, the court simply ordered Davis held in the county jail until space at the treatment facility became available.
However, this explanation does not resolve the unanswered question whether the court had authority to temporarily confine Davis in a county jail until space for him became *456 available at the treatment facility. We think it did.
To resolve the question, we look to the provisions for temporary custody in statutes governing confinement and probation. Iowa Code section 901.7 establishes the procedure for incarceration. For sentences exceeding one year, the statute requires the court to commit a defendant to the custody of the director of the Iowa department of corrections. The statute also allows the court to "make an order as appropriate for the temporary custody of the defendant pending the defendant's transfer to the custody of the director." Iowa Code § 901.7.
We interpreted this statute broadly in State v. Snyder, 336 N.W.2d 728 (Iowa 1983). In Snyder, we held that the district court did not exceed its authority when it ordered the defendant to be held at the county jail for thirty days while he attempted to arrange an out-of-state transfer. Snyder, 336 N.W.2d at 731. In so interpreting section 901.7, we rejected the defendant's dual contentions that the sentencing order was an attempt to (1) fix the place of confinement contrary to statute, and (2) arrange an out-of-state transfer without first committing the defendant to the custody of the director of adult corrections. As to the first contention, we reasoned that the sentencing order merely provided for temporary custody pending final delivery of the defendant to the custody of the director of adult corrections. As to the second contention, we viewed the sentencing order as one merely withholding final delivery of custody pending the investigation of other alternatives. Id.
Iowa Code section 907.8 governs probation:
....
When probation is granted, the court shall order said person committed to the custody, care, and supervision:
1. Of any suitable resident of this state; or
2. Of the judicial district department of correctional services.
....
... If the defendant is confined in the county jail at the time of sentence, the court may order the defendant held until arrangements are made by the judicial district department of correctional services for the defendant's employment and the defendant has signed the necessary probation papers.
Both section 901.7 (governing incarceration) and section 907.8 (governing probation) authorize the district court to provide for temporary custody before transfer to the custody of the entity or person responsible for a defendant's custody, care, and supervision. As we said, we have interpreted broadly the temporary custody provision in section 901.7. We likewise interpret broadly the temporary custody provision in section 907.8. Granted, section 907.8 provides that the court can order a defendant held in the county jail until arrangements are made for the defendant's employment. The reason confinement is linked to employment is obvious. Defendants are allowed to remain in the community at community-based residential facilities so that they can remain or become employed. Employment is a necessary prerequisite to rehabilitation.
We view section 907.8 as authorizing the district court to confine a defendant in a county jail until the judicial district department of correctional services makes arrangements for the defendant's employment. Obviously, where the court orders inpatient treatment, those arrangements would likely be delayed until after treatment is completed. In this case there was nothing in the record to suggest otherwise. Given this broad interpretation of section 907.8, we fail to see how the district court lacked authority to do what it did.
This case is a good example of why trial judges must have authority to do exactly what the trial judge did here and why we think the legislature intended judges to have such authority. Davis admitted to the presentence investigator that he had been drinking heavily before committing the offense in question. The presentence report lists a number of alcohol-related offenses in the year and a half leading up to the burglary in question: public intoxication (twice), consuming in public, and possession of alcohol underage. *457 In addition, Davis was convicted of petty theft twice. He violated his pretrial release agreement when he was arrested for criminal mischief, interference with official acts, and being in a tavern as a minor.
Given Davis' track record, the odds were good that he might commit more crime if he were allowed to roam the streets one week before inpatient treatment began. The trial judge realized that and did what any reasonable judge in similar circumstances would do: keep the defendant confined until inpatient treatment could begin.
In sum, we conclude the district court did not illegally sentence Davis to jail time on the felony offense of burglary as a condition of probation. Rather, the court merely ordered Davis held in the county jail until he could be transferred to a treatment facility to begin fulfilling his first probationary condition. The district court had statutory authority to enter such an order. We vacate the court of appeals decision to the contrary. We affirm the district court's judgment of conviction and sentence.
DECISION OF COURT OF APPEALS VACATED; DISTRICT COURT JUDGMENT AFFIRMED.
