
325 S.W.3d 556 (2010)
Harold S. DYKES, Appellant,
v.
MISSOURI DEPARTMENT OF CORRECTIONS, Respondent.
No. WD 72641.
Missouri Court of Appeals, Western District.
November 30, 2010.
*557 Harold S. Dykes, Cameron, MO, Appellant pro se.
John D. Hoelzer, St. Louis, MO, for respondent.
Before: ALOK AHUJA, P.J., and VICTOR C. HOWARD and CYNTHIA L. MARTIN, JJ.
ALOK AHUJA, Judge.
Harold Dykes is currently incarcerated based on his conviction in the Circuit Court for the City of St. Louis for stealing by deceit. He filed this declaratory judgment action contending that the Department of Corrections (the "Department" or "DOC") had incorrectly calculated the time he spent in custody prior to his conviction which should be credited toward service of his sentence. The circuit court granted the Department's motion for judgment on the pleadings, and Dykes appeals. We reverse in part, and remand for further proceedings.

Factual Background
Dykes pled the following facts in his Petition. During one week in 2004, Dykes committed a stealing offense in the City of St. Louis and a forgery offense in Scott County. Authorities in Scott County arrested him on a forgery charge on or about September 1, 2004. Dykes was held in jail in Scott County, and later in Mississippi County following a change of venue, awaiting *558 trial on the forgery charge. The Petition and attached exhibits reflect that a bond amount was established on the Scott County charge, which would have permitted Dykes' release pending the disposition of that charge.
On May 27, 2005, Dykes pled guilty to the Scott County forgery offense, and was sentenced to eighteen months in prison. He was remanded to the Department's custody to serve his forgery sentence in June 2005. Dykes alleges that he was paroled in connection with the forgery charge on August 24, 2005.
On October 30, 2004, while he was awaiting trial for the Scott County forgery offense, St. Louis authorities issued a warrant for Dykes' arrest. Dykes' Petition alleges that "St. Louis City lodged a detainer/warrant for [the stealing charge] during Dykes' incarceration for Forgery, but did not extradite Dykes for [the stealing] charge until Dykes' release for Forgery." The Petition alleges that this detainer was in place throughout the time period for which Dykes currently seeks credit.
Dykes' Petition alleges that he "was paroled to detainer in St. Louis on 8-24-05." After being transferred to the custody of St. Louis authorities, Dykes was released on bond on the stealing charge on August 30, 2005. Dykes' Petition states that he "was arrested for failure to appear on 4-26-2006 and remained at St. Louis City Justice Center until sentenced for [the stealing charge] on 2-29-2008."
Dykes was convicted by a jury in the Circuit Court for the City of St. Louis on the stealing by deceit charge, and, on February 29, 2008, was sentenced as a prior and persistent offender to fifteen years' imprisonment. He alleges that he was remanded to the DOC's custody for the St. Louis stealing conviction on March 20, 2008.
Dykes asked the DOC to give him credit against his sentence on the St. Louis stealing offense for that portion of the time that he was held in custody on the forgery offense during which the detainer for his stealing offense was active, i.e., from October 30, 2004, through August 24, 2005. The DOC denied this request. Dykes then brought the underlying declaratory judgment action seeking credit for this time.[1] The DOC moved for judgment on the pleadings, arguing that Dykes was not entitled to credit as a matter of law. The circuit court agreed, and granted the Department judgment on the pleadings. Dykes appeals.

Standard of Review
On appeal of a judgment on the pleadings we review the petition of the losing party to determine if the facts pled were insufficient as a matter of law. The grant of judgment on the pleadings is upheld where, holding all facts alleged in the opposing party's petition as true, the moving party was entitled to judgment as a matter of law.
Wallingford v. Mo. Dep't of Corr., 216 S.W.3d 695, 696 (Mo.App. W.D.2007) (citation omitted).

Analysis
For purposes of the discussion which follows, we divide the time period for which Dykes seeks time-served credit into two sub-periods: (1) the period following the lodging of the St. Louis detainer until Dykes' conviction of the Scott County forgery charge (i.e., the time period from October 30, 2004, through May 27, 2005); *559 and (2) the time period following his conviction and sentencing on the Scott County charges through the date on which his custody was transferred to St. Louis authorities (i.e., the period from May 27, 2005, through August 24, 2005).
As to both time periods, credit for time in custody is governed by § 558.031.1.[2] With exceptions not relevant here, the statute provides in relevant part:
A sentence of imprisonment shall commence when a person convicted of a crime in this state is received into the custody of the department of corrections or other place of confinement where the offender is sentenced. Such person shall receive credit toward the service of a sentence of imprisonment for all time in prison, jail or custody after the offense occurred and before the commencement of the sentence, when the time in custody was related to that offense....
§ 558.031.1 (emphasis added).[3]

I.
With respect to the first period of time at issuenamely, the time from the lodging of the St. Louis detainer, through the time of Dykes' conviction of the Scott County forgery offensewe believe the result here is controlled by our decisions in Wallingford and in Mikel v. McGuire, 264 S.W.3d 689 (Mo.App. W.D.2008). Under those decisions, Dykes stated a claim for credit for the first time period because his Petition reflects that: (1) he was entitled to pre-trial release on the Scott County charge; and (2) he was simultaneously subject to a detainer related to the St. Louis stealing charge.
As explained in the seminal decision in Goings v. Missouri Department of Corrections, 6 S.W.3d 906 (Mo. banc 1999), "[t]he purpose of section 558.031 undoubtedly is to eliminate the disparity of treatment between indigent defendants, who typically are in custody prior to sentencing, and non-indigents who typically are free on bond prior to sentencing." Id. at 908.
In Mikel, we observed that
[T]he Missouri Supreme Court has interpreted "related to" [in § 558.031.1] as a "very broad term" that is not restricted to "caused by" or "the result of" such that a person's "custody can be `related to' two offenses and the statutory credit will nevertheless apply." Cases subsequent to Goings suggest that incarceration is related to the subsequent offense where the person is eligible for release on bail on the prior offense, but the subsequent charge prevents the person's release from custody.
264 S.W.3d at 692 (citations omitted).
In Mikel, an inmate (Mikel) was initially arrested in the City of St. Louis for aggravated stalking and associated offenses, and was convicted there and remanded to the Department to serve his sentence. After his remand to the DOC, St. Louis County filed a detainer against Mikel for first-degree robbery and other charges. Although Mikel had not been the subject of a formal St. Louis County detainer during the time he was awaiting trial in the City, we held that he could be entitled to credit *560 on the St. Louis County sentence for the time spent awaiting trial in the City. We explained that, to obtain credit on the later, St. Louis County charges, Mikel "has to prove that the subsequent offense would have prevented his release from custody on the prior offense," id.; in other words, "summary judgment [for correctional officials] was only proper if there was no factual dispute as to whether the [St. Louis County robbery charge] would have prevented Mr. Mikel from being released assuming he posted bond on the City charges." Id.
After stating these principles, Mikel then examined the factual record, and concluded that conflicting evidence existed on two key issues: (1) whether the City had arrested Mikel on behalf of the County, or instead whether the City had acted independently; and (2) whether the City would have released Mikel if he had posted bond or resolved the City charges, or instead whether the City would have held him on behalf of the County, due to the unresolved County charges. Based on this conflicting evidence, this Court concluded that summary judgment on behalf of DOC officials had been improvidently entered:
Granting Mr. Mikel all reasonable inferences, the evidence could support a finding that, had he posted bond for aggravated stalking [as charged by the City of St. Louis], he would have been held in jail for robbery [as charged by the County], which would show that the robbery offense was related to his confinement from July 9, 2004, to November 23, 2004. As this issue was in dispute, the circuit court erred in deciding it against him.
Id. at 693. Thus, we held that the possibility that Mikel was subject to the functional equivalent of a detainer on the County charges while awaiting trial on the City charges was enough to create a triable issue preventing the grant of summary judgment to Department officials.
Similarly, Wallingford holds that an inmate who had been convicted on "offense I," but had access to an appeal bond for that offense, was entitled to credit under § 558.031.1 on "offense II" during the time he remained incarcerated while the appeal of his conviction for offense I was pending, because he was subject to a separate bond on offense II, which would have prevented his release even if he had posted the appeal bond required on offense I:
In this case, Mr. Wallingford had an appeal bond available for offense I, and at the same time, a pre-trial bond available for offense II. Unlike previous cases involving section 558.031, Mr. Wallingford did not have to remain in jail for the conviction on offense I because he had an appeal bond available to him. Yet, he would have had to remain in jail if he did not also pay the pre-trial bond for offense II. Therefore, the time in prison relates to both offenses. Such jail time should not be credited exclusively toward the sentence of offense I, because Mr. Wallingford was not required to be in jail for either offense, as long as he met the bond demands for both offenses. Thus, the jail time relates to both offenses, and his sentence under offense II should be credited with this time.
216 S.W.3d at 697.
This case is analogous to Mikel and Wallingford. Under those cases, time in custody is "related to" a subsequent offense where an inmate would not be entitled to release merely by satisfying the conditions imposed in connection with a prior offense; instead, to be released the inmate would also have to satisfy conditions imposed because of the subsequent *561 offense.[4] Here, the Petition and attached exhibits reflect that a bond had been established for the Scott County forgery charge. Further, the Petition alleges that a detainer had been lodged against Dykes by St. Louis authorities during the period for which he seeks credit under § 558.031.1. Therefore, as in Mikel and Wallingford, even if Dykes had posted bond on the Scott County forgery charges, he would nevertheless have been held pending disposition (or the setting and satisfaction of conditions of release) on the St. Louis charges. Thus, under the allegations of Dykes' Petition and the attached exhibits, he may be entitled to credit for the first period of time to which his Petition relatesnamely, the period from the lodging of the St. Louis detainer on October 30, 2004, through the date of Dykes' conviction and sentencing on the Scott County charge on May 27, 2005. The judgment on the pleadings granted to the Department must be reversed with respect to this period of time.
In reaching this conclusion, we recognize that this result would have been self-evident under the prior version of § 558.031.1. That statute, § 558.031.1(1), RSMo 1994, explicitly provided that "[t]ime spent in jail or prison awaiting trial for an offense because of a detainer for such offense shall be credited toward service of a sentence of imprisonment for that offense even though the person was confined awaiting trial for some unrelated bailable offense." See State ex rel. Lightfoot v. Schriro, 927 S.W.2d 467, 470-71 (Mo.App. W.D.1996).
Although the quoted language was repealed in 1995 in favor of the current version of the statute, we believe that, in this case, the result should be the same as under pre-1995 law. As Mikel explained, prior to 1995, "the statute explicitly required a detainer concerning the offense when `the person was [already] confined awaiting trial for some unrelated bailable offense.'" 264 S.W.3d at 691. The 1995 amendmentwhich added the "very broad" "related to" criterion to the statutehad the effect of expanding the circumstances in which an inmate could obtain credit against his sentence on a second offense, for time awaiting trial on another offense. Although a formal detainer may have been necessary under prior law, after 1995 "[a] detainer or an arrest warrant concerning the subsequent offense is not needed to prove that time in custody was related to that offense." Id. at 692. This is exemplified by Mikel itself, where the Court concluded that time in custody could be "related to" a subsequent offense despite the lack of a detainer, where other evidence indicated that the inmate had been arrested because of the subsequent offense, and thatdetainer or nothe inmate would not have been released following disposition of the earlier offense without also resolving the subsequent offense. Id. But although a formally lodged detainer is no longer necessary to prove a "related to" claim in this context, the existence of a detainer is highly probative as to whether incarceration "relates to" the subsequent offense.[5]


*562 II.
We reach the opposite result as to the second period of time at issue here, namely the period from Dykes' conviction and sentencing on the Scott County forgery charge on May 27, 2005, through his parole on that offense on August 24, 2005. "For time in custody to be `related to' an offense, there must be some right to be free from custody absent the subsequent offensesuch as on parole, on bail, or on bond." Pettis v. Mo. Dep't of Corr., 275 S.W.3d 313, 318 (Mo.App. W.D.2008). "A charge is unrelated to the time in custody where an inmate would have been in prison anyway." Id. Thus, where "the prisoner was not entitled to bail on the first offense," time in custody generally cannot be "related to" a second offense because the inmate "`would have been in custody serving the sentence on the first offense regardless.'" Id. (quoting Belton v. Moore, 112 S.W.3d 1, 5 (Mo.App. W.D.2003)); see also Kelly, 58 S.W.3d at 518-19.
Under these decisions, once Dykes had been convicted and sentenced on the Scott County charges, he was not eligible for bail on that offense, and therefore would have remained incarcerated irrespective of the status or disposition of the St. Louis stealing charges. As a matter of law, then, his post-May 27, 2005 custody could not be "related to" the stealing charges, and he was not entitled to credit toward the sentence on his stealing conviction while he was imprisoned for forgery.

Conclusion
For the reasons stated above, the circuit court's judgment is reversed with respect to Dykes' claim for credit for time served for the period from October 30, 2004, through May 27, 2005. Dykes' claim for credit for that time period is remanded to the circuit court for further proceedings. In all other respects the circuit court's judgment is affirmed.
All concur.
NOTES
[1]  Dykes' declaratory judgment action was originally filed in the Circuit Court for the City of St. Louis but was transferred on venue grounds to the Cole County Circuit Court.
[2]  Statutory citations are to the RSMo 2000, as updated through the 2009 Cumulative Supplement, unless otherwise indicated.
[3]  As in Anderson v. Crawford, 309 S.W.3d 863 (Mo.App. W.D.2010), "[t]he State does not dispute that this declaratory judgment action is the appropriate mechanism for [Dykes] to obtain judicial review of the Department's calculation" of the credit to which he is entitled under § 558.031.1. Id. at 866 n. 4 (collecting cases).
[4]  This assumes, of course, that the inmate is eligible for conditional release on the prior offense; as we discuss infra § II, where an inmate is not eligible for bail on the first offense, the second offense generally does not "relate to" the time in custody on the first offense.
[5]  Dykes also argues for credit by emphasizing the purported factual relationship between the Scott County and St. Louis offenses, including similarities in his modus operandi in the two offenses, and the fact that the discovery of his involvement in the Scott County offense may have led to his identification as the perpetrator of the St. Louis offense. But these factual connections between the underlying offenses are not germane under § 558.031.1: "It is not the relationship of the specific facts underlying two convictions, or the fact that two charges were initially tried at the same time and involved the same victim, that is determinative of jail-time credit for purposes of section 558.031. Under section 558.031, it is to `the time in custody' that the second conviction must be related." State ex rel. Nixon v. Kelly, 58 S.W.3d 513, 518-19 (Mo. banc 2001).
