
216 S.W.3d 695 (2007)
John A. WALLINGFORD, Appellant,
v.
MISSOURI DEPARTMENT OF CORRECTIONS, Respondent.
No. WD 66366.
Missouri Court of Appeals, Western District.
March 6, 2007.
*696 John A. Wallingford, Tipton, pro se.
Andrew W. Hassell, Jefferson City, for Respondent.
Before THOMAS H. NEWTON, P.J., PATRICIA A. BRECKENRIDGE, and JOSEPH M. ELLIS, JJ.
THOMAS H. NEWTON, Presiding Judge.

Factual and Procedural Background
While Mr. John Wallingford was on trial for three counts of delivery of a controlled substance (offense I), he was charged with an additional three counts of delivery of a controlled substance (offense II), which he committed while he was out on bail from offense I. Mr. Wallingford was convicted at trial for offense I on March 17, 2000, and his appeal bond was set at $200,000. His conviction was affirmed on May 24, 2001. He did not pay his appeal bond and remained in prison during this time. While he was in jail awaiting his appeal, he also had a pre-trial bond available to him until he pled guilty to offense II on May 11, 2001.
Mr. Wallingford petitioned the trial court for jail time credit for offense II for the time he was in prison from March 17, 2000, to May 11, 2001. The State filed a motion for judgment on the pleadings, which the trial court granted. Mr. Wallingford appeals.

Analysis
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. State ex. rel. Nixon v. Am. Tobacco Co., 34 S.W.3d 122, 134 (Mo. banc 2000). 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. Id. We find that the State was not entitled to judgment as a matter of law, reverse the decision of the trial court, and remand for further proceedings.
The law governing jail time credit was amended in 1995. Cf. RSMo § 558.031.1 (1986) and RSMo § 558.031.1 (2000). Under the pre-amendment statute, jail time credit was given for "[t]ime spent in jail or prison awaiting trial for an offense because of a detainer for such offense . . . even though the person was confined awaiting trial for some unrelated bailable offense." § 558.031.1(1) (1986). Under the amended statute, a "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 (2000). A prison sentence commences when a person is convicted. Id.
Thus, offense II must be related to the time spent in prison in order to get jail time credit for offense II for time spent in jail on offense I. State ex. rel. Nixon v. Kelly examines the case that most closely resembles ours. 58 S.W.3d 513 (Mo. banc 2001). In that case, Mr. Haldeman was initially charged and convicted of two counts of the same crime against the same *697 person. Id. at 515. The trial court granted a new trial on one of the counts and upheld the conviction on the other count. Id. Mr. Haldeman appealed the conviction on the first count and was free on an appeal bond pending the appeal. Id. The conviction was affirmed and he was taken into custody. Id. In the meantime, the State decided to retry the second count, and he was tried and convicted on the second count the year after he was imprisoned for the first count. Id. Mr. Haldeman asked for jail time credit under section 558.031.1. Id. Analyzing the "related to" language of section 558.031.1, the Supreme Court held that "even absent [his] arrest, trial or conviction on [offense] II, he would have been in prison on [offense] I" because there was no bond available on offense I. Id. at 519. Additionally, there was nothing in the record to suggest that "[a]bsent [offense] I . . . he would not have been out on bail on the charge that resulted in [offense] II." Id. Thus, the prisoner was not entitled to jail time credit in Kelly because the time spent in prison was solely related to [offense] I.
The Western District has held that a prisoner ineligible for bail on the sentence of his first offense would have been in jail regardless of the second offense, and, therefore, the jail time for the first offense is not related to the second offense. Belton v. Moore, 112 S.W.3d 1, 4 (Mo.App. W.D.2003). Thus, under a conviction for which no appeal bond is available, the prisoner must be in prison for that offense; therefore, a second offense is considered unrelated to that jail time, and no jail time credit is available for the second offense. See id. By extension if an appeal bond is available for a conviction, the prisoner could have been free on bond on that offense, and the time in prison should be credited to his other offense.
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.
Mr. Wallingford also makes an argument about the constitutionality of section 558.031. Questions of constitutionality must be presented in a motion before the trial or they are waived. Rule 24.04(b)(2); State v. William, 100 S.W.3d 828, 831 (Mo.App. W.D.2003). If the constitutional issue is not raised at the earliest opportunity, it is waived. William, 100 S.W.3d at 831. Mr. Wallingford presents the constitutional issues for the first time in this appeal. He should have raised them in a motion in response to the State's motion for judgment on the pleadings. Thus, the issue is waived and is not preserved for appellate review.
For the foregoing reasons we reverse and remand for further proceedings consistent with this opinion.
PATRICIA A. BRECKENRIDGE, and JOSEPH M. ELLIS, JJ., Concur.
