We granted certiorari to review an unpublished decision of the court of appeals (No. 82CA597), which affirmed a judgment of the District Court of Jefferson County denying credit to the defendant, Walter Joe Schubert, for . presentence confinement served in connection with charges separate and distinct from the offenses for which the defendant was ultimately sentenced. The court of appeals held that section 16-11-306, 8 C.R.S. (1984 Supp.), requires a sentencing court to credit a defendant only for that part of presentence confinement attributable to the criminal transaction for which the defendant is to be sentenced and not for confinement attributable to an unrelated criminal charge or conviction. We affirm the judgment of the court of appeals.
I.
On October 3, 1980, the defendant was arrested and charged on two counts of second degree burglary of a dwelling1 allegedly committed on April 1 and April 3, 1980, in Jefferson County, Colorado. Prior to his arrest on the burglary charges, the defendant had been charged in the District Court of Boulder County with felony menacing2 and unlawfully carrying a concealed weapon.3 On June 10, 1980, he tendered guilty pleas to these charges and was granted a deferred judgment and sentence conditioned on his participation in a rehabilitative program at the Colorado State Hospital. The defendant received an unsatisfactory discharge from the hospital on August 7, 1980, and his status on the Boulder charges was not yet resolved when he was arrested for the Jefferson County burglaries on October 3, 1980.
Following his arrest in Jefferson County, bail was set in the amount of $2,000, but the defendant was unable to post the bail and remained in the Jefferson County jail for fifty-two days from October 3,1980, to November 23,1980. On November 23 the District Court of Jefferson *791County authorized the defendant’s transfer to the Boulder County jail for resolution of the deferred judgment and sentence pending in the Boulder District Court.4 The defendant remained in custody in the Boulder jail from November 23 to December IT, 1980, when the District Court of Boulder County revoked the deferred judgment and sentence and granted him probation on the condition that he be confined in the county jail on a work release program and be later transferred to a community corrections facility.
On December 29, 1980, while confined in the Boulder County jail on the work release program, the defendant was taken to the District Court of Jefferson County for the entry of not guilty pleas to the pending second degree burglary charges. The defendant was then returned to the Boulder County jail and remained there on the work release program until January 9, 1981, when he was transferred to Empathy House, a Boulder community corrections facility. Upon his transfer to the community corrections facility, the District Court of Jefferson County granted the defendant a personal recognizance bond on the pending Jefferson County burglary charges on the condition that the defendant remain at the community corrections facility. The defendant remained at Empathy House until March 27, 1981, when he absconded and fled to California.
On June 16, 1981, the defendant pled guilty in California to assault with a deadly weapon and was ordered to serve a one-year county jail sentence as a condition of probation.5 On December 3, 1981, he was extradited to Colorado and was transferred to the Jefferson County jail on December 4, 1981. Except for a brief transfer to the District Court of Boulder County for resolution of a petition to revoke his probation,6 the defendant remained in the Jefferson County jail until the final resolution of the charges pending there against him on March 15, 1982. This period of confinement in the Jefferson County jail totalled 102 days.
On January 14, 1982, the defendant, pursuant to a plea agreement, entered guilty pleas to two counts of attempted second degree burglary of a building in exchange for the dismissal of the two counts of second degree burglary of a dwélling.7 The District Court of Jefferson County sentenced the defendant on March 15, 1982, to concurrent sentences of two years on each of his attempted burglary convictions and credited him with presentence confinement *792of 154 days.8 The 154 day credit represented those periods which the defendant spent in the Jefferson County jail awaiting disposition of the pending burglary charges, namely, the 52 days from October 3, 1980, to November 23, 1980, and the 102 days from December 4, 1981, to March 15, 1982. The sentencing court, however, expressly refused to credit against the sentence those periods of confinement or detention spent in the Boulder County jail, the Boulder County work release program, and the Boulder community corrections facility in connection with the charges pending against him in the Boulder District Court.
The defendant appealed his sentence to the court of appeals. In affirming the sentence, the court of appeals held that section 16-11-306, 8 C.R.S. (1984 Supp.), implicitly limits the right to presentence confinement credit to that confinement served in connection with the transaction for which the offender is to be sentenced.9 We granted certiorari to consider whether section 16-11-306, 8 C.R.S. (1984 Supp.), requires credit for presentence confinement when such confinement is attributable to criminal charges which are separate and distinct from the charge or conduct for which the defendant is ultimately sentenced.
II.
Before addressing the merits of the issue before us, we first review the state of the law which preceded the enactment of section 16-11-306, 8 C.R.S. (1984 Supp.). Pri- or to 1972 there was no statute addressing the question of credit for presentence confinement. In People v. Jones, 176 Colo. 61, 489 P.2d 596 (1971), this court, after noting that credit for presentence confinement was not a matter of constitutional or statutory right, strongly recommended as a better practice the granting of credit for all time spent in custody as a result of the criminal transaction for which a sentence was to be imposed. The legislature responded to the Jones decision by enacting in 1972 section 39-11-306 as part of the Colorado Code of Criminal Procedure. Ch. 44, sec. 1, § 39-11-306, 1972 Colo.Sess. Laws 190, 249. This 1972 statute provided as follows:
(1) In sentencing a defendant to imprisonment the sentencing judge shall take into consideration that part of any presentence confinement which the defendant has undergone with respect to the transaction for which he is to be sentenced.
(2) The judge shall state in pronouncing sentence, and the judgment shall recite, that such consideration has been given, but no sentence shall be set aside or modified on review because of alleged failure to give such consideration unless the record clearly shows that the judge did not, in fact, consider such presen-tence confinement when imposing sentence.
*793(3) If the maximum sentence imposed is longer than the statutory maximum for the offense less the amount of allowable presentenee confinement, it shall be presumed that the judge did not consider the presentence confinement.
This original statute, which was renumbered as section 16-11-306 in the 1973 Colorado Revised Statutes,10 was consistently construed by this court to mean that a sentencing judge, although under legal obligation to consider presentence confinement, was not required to actually grant the defendant credit for such confinement. People v. Reed, 190 Colo. 517, 549 P.2d 1086 (1976); accord, e.g., People v. Martinez, 192 Colo. 388, 559 P.2d 228 (1977); People v. Lobato, 192 Colo. 357, 559 P.2d 224 (1977).
It was against this backdrop of prior statutory and decisional law that the legislature in 1979 repealed section 16-11-306 and reenacted it in the following amended form:
A person who is confined prior to the imposition of sentence is entitled to credit against the term of his sentence for the entire period of such confinement. At the time of sentencing, the court shall make a finding of the amount of presentence confinement to which the offender is entitled and shall include such finding in the mitti-mus. Such period of confinement shall be deducted by the Department of Corrections.
Ch. 157, sec. 7, § 16-11-306, 1979 Colo. Sess.Laws 664, 665-66.
III.
Focusing his argument on the legislative omission in the 1979 version of section 16-11-306 of that phrase which limited presen-fence confinement credit to the jail time “which the defendant has undergone with respect to the transaction for which he is to be sentenced,” the defendant argues that it must be presumed that the legislature thereby intended to change the law so as to require credit for all periods of presentence confinement without regard to whether such confinement is related to the transaction for which an offender is ultimately sentenced. We conclude that section 16-11-306, 8 C.R.S. (1984 Supp.), was intended to create a statutory entitlement to credit only with respect to the presentence confinement served in connection with the charge or conduct for which a particular sentence is imposed and that, consequently, the defendant in this case was not entitled to credit for the periods of his confinement or detention in Boulder on charges separate and distinct from those for which he was sentenced by the District Court of Jefferson County.11
Legislative intent is the polestar of statutory construction. E.g., People v. Lee, 180 Colo. 376, 381, 506 P.2d 136, 139 (1973). If at all feasible, a statute should be given that construction which will render it effective in accomplishing the purpose for which it was enacted. E.g., In re Questions by United States District Court, 179 Colo. 270, 274-75, 499 P.2d 1169, 1171 (1972); Cross v. People, 122 Colo. 469, 471-72, 223 P.2d 202, 203 (1950); 2A Sutherland Statutory Construction § 45.09 (C. Sands 4th ed. 1973). In ascertaining the legislative purpose, courts should consider the state of the law preexisting the legislative enactment, the prob*794lem addressed by the legislation in question, and the statutory remedy created to cure the problem. E.g., People v. Sneed, 183 Colo. 96, 99, 514 P.2d 776, 778 (1973); People v. Rapini, 107 Colo. 363, 366, 112 P.2d 551, 552 (1941). Furthermore, it must be presumed that the legislature intended a just and reasonable result as well as a result feasible of execution. § 2-4-201(l)(c) and (d), IB C.R.S. (1980). Weighing the consequences of a particular construction against these statutory presumptions serves to achieve a statutory interpretation that accords with those goals sought to be achieved by the legislation in question.
As discussed in Part II of this opinion, the state of the law antedating the 1979 statute only required a sentencing judge to consider presentence confinement served by an offender with respect to the transaction for which he was to be sentenced, but did not vest the offender with a statutory entitlement to credit for such confinement. The problem addressed by the 1979 enactment was the unequal treatment of indigent offenders who, due to their inability to post bail and the statutory discretion reposed in sentencing courts to grant or refuse credit for presentence confinement, would serve longer periods in jail than their wealthier counterparts who were able to avoid presentence confinement by posting bail and thereby secure their pre-sentence freedom. The 1979 version of section 16-11-306 provides a remedy to cure this inequality by expressly granting an offender “who is confined prior to the imposition of sentence” a statutory entitlement “to credit against the term of his sentence for the entire period of such confinement.”
In view of the obvious purpose underlying the 1979 version of section 16-11-306, we believe the construction most suited to effectuate that purpose is to vest an offender with a statutory entitlement to credit for presentence confinement for the longer of the following periods of confinement: the time served as the result of the charge for which the sentence is imposed or, what will undoubtedly be the longer period in most cases, the time served as the result of the conduct on which such charge is based. The applicable period of credit is stated in the alternative in order to account for the period of delay frequently occurring between the arrest of an offender for particular criminal conduct and the filing of a formal charge based on that conduct and also to provide credit for the longer period of time in those instances where, pursuant to a plea agreement, an accused pleads guilty to a late filed charge in exchange for the dismissal of the originally filed charge. See ABA Standards Relating to Sentencing Alternatives and Procedures § 18-4.-7(a) (1979). This construction achieves the legislative purpose of affording relief to those offenders whose indigency prevented them from gaining their pretrial freedom prior to sentencing by posting bail in the criminal case filed against them. The alternative construction urged by the defendant, under which an offender would be entitled to credit for presentence confinement on unrelated charges or convictions, totally ignores the basic purpose for which the 1979 statute was enacted. In the case of an offender confined on some other charge or conviction unrelated to the charge or conduct for which he is to be sentenced, the presentence deprivation of liberty is not attributable to the offender’s financial inability to post bail in the case in which the sentence is ultimately imposed, but to a criminal matter which constitutes a separate and independent cause of his confinement.12
*795To construe section 16-11-306 as requiring credit for any presentence confinement served in connection with an unrelated criminal charge or sentence would produce adverse consequences for the administration of justice that were obviously beyond the contemplation of the legislature. Such construction, for example, would result in duplicative sentencing credits to the offender whose presentence confinement is attributable to another charge unrelated to the charge for which the sentence is imposed and who is later sentenced on the unrelated charge with a concomitant credit for the same period of presentence confinement. This construction would also result in double credit for the offender who prior to sentencing was already serving time on a previously imposed sentence. Duplicative . credits in such circumstances not only would reward the multiple offender but also would vitiate, to the extent of such credit, the statutory penalty applicable to the crime for which a particular sentence is imposed. See People v. Saiz, 660 P.2d 2, 7 (Colo.App.1982). Such consequences, in our view, are the very antithesis of the purpose which the legislature sought to achieve in enacting the 1979 version of section 16-11-306 — that is, to eliminate the unequal treatment resulting to indigent offenders who might otherwise receive no credit for presentence confinement with respect to the charge or conduct for which they are sentenced.
We thus hold that section 16-11-306 requires a sentencing judge to credit a defendant with that period of time spent in custody as the result of the charge for which the sentence is imposed or as the result of the conduct on which such charge is based. In determining whether a particular period of presentence confinement qualifies for credit under section 16 — 11— 306, it is appropriate to ask the following question: Was the presentence confinement actually caused by the charge or conduct for which the offender is to be sentenced? People v. Brown, 107 Cal.App.3d 858, 864, 166 Cal.Rptr. 144, 147 (1980); see also Saiz, 660 P.2d at 7. While causation in this context does not mean that the charge or conduct for which the sentence is to be imposed must be the exclusive cause of the offender’s confinement, it does mean that there must be a substantial nexus between such charge or conduct and the period of confinement for which credit is sought. If, for example, multiple counts or cases are concurrently filed against a defendant in the same jurisdiction, and the defendant remains confined in that jurisdiction on all charges due to his inability to post bail, each charge would appropriately be considered a cause of the defendant’s presentence confinement. See People v. Brown, 107 Cal.App.3d 858, 864, 166 Cal. Rptr. 144, 147 (1980). In the case of concurrent sentences, the period of presen-tence confinement should be credited against each sentence. This is so because concurrent sentences obviously commence at the same time and in functional effect result in one term of imprisonment represented by the longest of the concurrent sentences imposed. Only by giving credit against each concurrent sentence will the defendant be assured of receiving credit for the full period of presentence confinement against the total term of imprisonment. When consecutive sentences are imposed, crediting the period of presentence confinement against one of the sentences will assure the defendant full credit against the total term of imprisonment. If only one sentence is ultimately imposed and the other concurrently filed counts or cases are dismissed, then clearly the de*796fendant should be credited with the entire period of presentence confinement served in the sentencing jurisdiction against the sentence.13 Where, however, the record shows that a particular period of confinement served prior to the imposition of sentence is not attributable to the charge or conduct for which a sentence is to be imposed, neither is the offender entitled to credit for such confinement nor does the sentencing judge err by denying credit under such circumstances.14
IV.
In this case, the defendant’s confinement in Boulder was not caused by the Jefferson County burglary transactions for which the defendant was sentenced on March 15, 1982. On the contrary, the period of the defendant’s Boulder confinement was directly related to and arose out of the charges pending against him in the District Court of Boulder County. It is true that the District Court of Jefferson County on November 23, 1980, while the defendant was confined in the Jefferson County jail, authorized the defendant’s transfer to the Boulder County jail for resolution of the criminal charges pending against him in that jurisdiction. The fact remains, however, that it was the unresolved menacing and weapon charges in Boulder that caused the defendant’s subsequent incarceration and detention in the Boulder County jail, *797the work release program, and the community corrections facility. Moreover, the transfer of the defendant to the jurisdiction of the District Court of Boulder County permitted the defendant to obtain a resolution of the Boulder criminal charges and to serve the Boulder sentence at a much earlier time than would have been the case if he had not been transferred. Because the defendant’s confinement and detention in the Boulder County jail and in the Boulder work release program and community corrections facility were not caused by the criminal charges or conduct on which the Jefferson County prosecution was based, the defendant was not entitled to credit for these periods of time against the Jefferson County sentences.
The extent of the defendant’s entitlement to presentence confinement amounted to 154 days, which represents the period served by the defendant in the Jefferson County jail in connection with the burglary transactions for which he was ultimately sentenced on March 15, 1982. Because the sentencing judge gave the defendant full credit for this 154 day period, we find no error in the allocation of presen-tence confinement credit with respect to the sentences imposed in this case.
The judgment is affirmed.
LOHR, J., specially concurs.. § 18-4-203, 8 C.R.S. (1978).
. § 18-3-206, 8 C.R.S. (1978).
.§ 18-12-105(1), 8 C.R.S. (1978).
. A deferred judgment and sentence, which is an alternative to the traditional plea of guilty, permits a defendant to plead guilty without the entry of a judgment of conviction and accords him the opportunity to withdraw that plea and obtain a dismissal of the charges with prejudice upon compliance with stipulated conditions during the period of deferral. § 16-7-403, 8 C.R.S. (1978 & 1984 Supp.). If, however, the court determines that the defendant has violated the conditions of the deferred judgment and sentence, then the court must enter a judgment of conviction and must impose sentence and either sentence the defendant to a term of imprisonment or to a term of probation. See, e.g., People v. Widhalm, 642 P.2d 498 (Colo.1982).
. The presentence report filed with the Jefferson County District Court states that the California court placed the defendant on unsupervised probation for three years on condition that he serve a 365 day term in a county jail either in California or Colorado. The California court gave Schubert credit for sixty days already spent in California confinement as of the sentencing date.
. The hearing on the Boulder case took place on December 30, 1981, at which time the defendant was placed on probation for one year retroactive to November 1980 and his probation was terminated as of the hearing date. So far as the record shows, this transfer to Boulder did not result in the defendant spending any time in the Boulder County jail, and he was apparently returned to the Jefferson County jail on the same day.
. §§ 18-2-101 and 18-4-203, 8 C.R.S. (1978). Attempted second degree burglary of a building is a class 5 felony which on the date of Schubert’s offenses was punishable by a presumptive sentence of 1 to 2 years, plus one year of parole. § 18-l-105(l)(a)(I), 8 C.R.S. (1984 Supp.). Second degree burglary of a dwelling, in contrast, is a class 3 felony and was punishable by a presumptive sentence of 4 to 8 years, plus one year of parole. § 18-4-203, 8 C.R.S. (1978); § 18-l-105(l)(a)(I), 8 C.R.S. (1984 Supp.).
. At the presentence hearing on March 15, 1982, a probation officer testified that the total amount of time spent by the defendant in pre-sentence confinement was 276 days, which represented the 154 days of presentence confinement in the Jefferson County jail and the additional period of presentence confinement in the Boulder County jail, the Boulder County work release program, and the Boulder community corrections facility.
. The court of appeals, assuming arguendo that the defendant’s detention in the Boulder work release and community corrections programs might somehow have been related to the Jefferson County charges, held that detention under work release and community corrections programs did not constitute confinement as contemplated by section 16-11-306, 8 C.R.S. (1984 Supp.). In view of our determination that the defendant's detention in Boulder under the work release program and in the community corrections facility related to charges separate and distinct from the Jefferson County transactions for which the defendant was ultimately sentenced, it is unnecessary for us to decide whether detention served under a work release program or in a community corrections facility constitutes confinement within the intendment of section 16-11-306. See People v. Lee, 678 P.2d 1030 (Colo.App.1983) (commitment to county jail in conjunction with work release program entitles offender only to credit for actual time confined in county jail and not time at work); People v. Radar, 652 P.2d 1085 (Colo.App.1982) (residency in community corrections facility as condition of probation is not presen-tence confinement).
. Minor amendments not pertinent here were enacted in 1973, ch. 147, sec. 1, § 39-11-306, 1973 Colo.Sess.Laws 506; in 1974, ch. 102, sec. 25, § 39-11-306, 1974 Colo.Sess.Laws 401, 408; and in 1977, ch. 216, sec. 10, § 16-11-306(3), 1977 Colo.Sess.Laws 861, 865.
. The defendant at one point in his brief claims entitlement to all presentence confinement, which obviously would include the 7 ½ months served in the California jail prior to his return to Colorado. At another point in his brief the defendant seems to argue only for credit for 122 days spent by him in the Boulder County jail, the work release program, and the community corrections facility in connection with the Boulder charges. The court of appeals interpreted the defendant’s claim for presen-tence confinement credit to be limited to the period of his Boulder confinement and detention, as do we. Our resolution of this case is such, however, that, whatever the scope of the defendant’s claim, his only statutory entitlement to sentencing credit is for the 154 days of pre-sentence confinement with respect to the Jefferson County transactions for which he was sentenced.
. We are not unmindful of the rule of lenity, but find it inapplicable here. This rule requires that ambiguities in criminal statutes be resolved strictly in favor of the accused. E.g., People v. Lowe, 660 P.2d 1261 (Colo.1983); People v. Cornelison, 192 Colo. 337, 559 P.2d 1102 (1977). The rule of lenity, however, is intended only to resolve an unyielding ambiguity in statutory language and should not be employed to create a statutory ambiguity in complete disregard of the clear purpose of the legislative enactment. E.g., Perrin v. United. States, 444 U.S. 37, 49 n. 13, 100 S.Ct. 311, 317 n. 13, 62 L.Ed.2d 199 (1979); Callanan v. United States, 364 U.S. 587, *795596, 81 S.Ct. 321, 326, 5 L.Ed.2d 312 (1961). The state of the law antedating the 1979 version of section 16-11-306 shows that the purpose of the 1979 statute was not to create an unqualified right to credit for all forms of presentence confinement regardless of their relationship to the sentence in question, but rather was to eliminate the discretionary power of the court to grant or withhold credit even when the presen-fence confinement was directly attributable to the charge or conduct for which the sentence in question was imposed. We believe the 1979 version of section 16-11-306, therefore, should be construed in light of its purpose and with an eye toward avoiding the adverse consequences on the administration of justice that might otherwise follow from a construction not contemplated by the legislature.
. If the case on which the defendant is sentenced has been only recently filed, but the defendant has been confined in jail in the sentencing jurisdiction for a much longer period of time on an older case that relates to a separate criminal transaction and is to be dismissed as part of a plea agreement, then the most recently filed case on which the sentence is imposed would not be the cause of the presentence confinement antedating the filing of the case resulting in the sentence. Although the defendant would be entitled to credit only for that period of presentence confinement attributable to the case resulting in the sentence, the parties nonetheless could agree as part of a sentence concession that credit should be given for the entire period of presentence confinement. § 16-7-301(2)(a), 8 C.R.S. (1978). If the court concurs in such concession, credit could then be given for the entire period of presentence confinement.
. Our construction of section 16-11-306, 8 C.R.S. (1984 Supp.), which limits credit for pre-sentence confinement to the period of confinement caused by the charge or conduct for which an offender is to be sentenced, is consistent with our construction of the pre-1979 version of section 16-11-306. People v. Emig, 676 P.2d 1156 (Colo.1984); People v. Loggins, 628 P.2d 111 (Colo.1981). Our construction also finds support in decisions of other courts which, in construing their respective statutes, quite consistently have denied presentence confinement credit for time served on charges unrelated to the charge or conduct for which the offender was sentenced. E.g., In re Rojas, 23 Cal.3d 152, 588 P.2d 789, 151 Cal.Rptr. 649 (1979) (defendant previously serving sentence on unrelated manslaughter charge not entitled to credit for that time on sentence for second degree murder where California statute specified that presen-tence confinement credit "shall be given only where the custody to be credited is attributable to proceedings related to the same conduct for which the defendant has been convicted"*); People v. Brents, 115 Ill.App.3d 717, 71 Ill.Dec. 222, 450 N.E.2d 910 (1983) (no credit allowed toward robbery sentence for time spent in custody on criminal contempt charge under Illinois statute authorizing credit “for time spent in custody as a result of the offense for which the sentence was imposed”); State v. Calderon, 233 Kan. 87, 661 P.2d 781 (1983) (Kansas statute specifying credit in the form of “an allowance for the time which the defendant has spent incarcerated pending the disposition of the defendant’s case” does not authorize credit on sentence for sodomy for time spent in custody for kidnapping charge arising in another county, even though sodomy charges were pending during confinement for kidnapping charge); Handley v. Commonwealth, 653 S.W.2d 165 (Ky.Ct.App.1983) (Kentucky statute granting credit for "[t]ime spent in custody prior to the commencement of a sentence as a result of the charge that culminated in the sentence” does not authorize credit on sentence for forgery for time spent in custody on charges filed in another county for criminal possession of a forged instrument); Commonwealth v. Foley, 15 Mass.App. 965, 446 N.E.2d 737 (1983) (no credit on sentence for assault where defendant confined for unrelated crime under Massachusetts statute granting credit for "the number of days spent by the prisoner in confinement prior to such sentence”); State v. Eugene, 340 N.W.2d 18 (N.D.1983) (North Dakota statute granting credit "for all time spent in custody as a result of the criminal charge for which the sentence was imposed, or as a result of the conduct on which such charge was based,” does not authorize credit on sentence for burglary for time spent in custody on charges of possession of stolen property and negligent homicide).