OPINION BY
Judge PELLEGRINI.Before this Court are preliminary objections filed by the Commonwealth of Pennsylvania, Department of Corrections (Department) in response to a petition for writ of mandamus filed by Tyrone Collins (Collins) requesting this Court to direct the Department to calculate his sentence in accordance with the order of the sentencing judge.
Collins is currently an inmate at the State Correctional Institution at Pittsburgh (SCI-Pittsburgh) as a result of pleading no contest or being convicted of three separate narcotics criminal complaints (CC) following his arrest on August 24, 1988. Collins was sentenced to serve seven-and-one-half to fifteen years to run concurrently on two of the charges1 and three to fifteen years2 on the other charge, but initially it was to run consecutively to the other two charges.
Collins appealed all three sentences. On January 7, 1991, the Superior Court of Pennsylvania (No. 363 Pittsburgh 1989) affirmed two of the sentences, but vacated one of the seven-and-one-half to fifteen year sentences3 because the sentencing court failed to advise Collins of his right to file post-trial motions and this case was remanded to the trial court. The case remained pending until June 15, 1993, when Collins pled no contest and received a sentence of time served to fifteen years to be served concurrently with the other sentences.4 As a result of the granting of post-conviction relief and the new sentence on the previously vacated sentence, there is no dispute that the sentencing court ordered that all three sentences were to be served concurrently, and that the maxi*1028mum release date was to be the same for' all three sentences.
However, the Department stopped crediting Collins with time served on the CC88-09392 conviction from the period the original sentence was vacated until he was resentenced on June 15, 1993, thereby ex-, tending his maximum date on that charge to January 31, 2006, instead of August 24, 2003 — the maximum date to which he would have been entitled if he had not been successful on appeal.5 The Department did so averring that when the sentence was vacated by the Superior Court, he could not be considered as having served time against that sentence.
Collins filed a petition for review in the nature of mandamus alleging that the Department inaccurately designated January 31, 2006, as his maximum release date, and arguing that the Department cannot suspend credit on the sentence of an inmate pending a final disposition on appeal when the inmate has already begun to serve that sentence and remains incarcerated.6 The Department filed preliminary objections in the nature of a demurrer arguing that Collins did not establish a clear legal right to relief or a corresponding duty for the Department to release him, because the Department acted properly when it did not include the two-and-one-half year time period between the Superior Court’s order to vacate Collins’ original sentence and the new sentence as time served on that charge.7
The sole issue in this case is where a defendant successfully appeals a conviction that includes a sentence that runs concurrently with another sentenee(s), and the new sentence likewise provides that the sentence is to run concurrently with the other sentence, does the defendant receive credit for the time between when the order to vacate the old sentence is issued and the new sentence is imposed?
In its preliminary objections, the Department contends that mandamus does not lie to require it to credit that time because the trial court’s order was illegal under 42 Pa.C.S. § 9760 of the Sentencing Code.8 Specifically, relying on subsections (1) and (4) of 42 Pa.C.S. § 9760, it argues *1029that during the period between Collins’ successful appeal and his plea and resen-tence, he was not in custody as a result of that conviction. Because he was not in custody on that conviction, it argues then that the trial court could not direct that a sentence begin on a date prior to the date of sentencing when Collins was serving time on an unrelated charge.9 In response, Collins argues that not only does Section 9760 of the Sentencing Code allow a trial court do so, but that to hold otherwise would violate his due process rights because his successful appeal with the same maximum sentence would result in a longer sentence than if he had not appealed, which is in direct contravention of the trial court’s order.
If one looks only at Section 9760 of the Sentencing Code, whether a defendant receives credit for the time between when the order is vacated and a new sentence is imposed appears to fall between the seams of its various subsections because nothing directly addresses that situation. What appears to be this gap in practice is not one because, analytically, when the trial court resentences after an appeal is vacated or post-conviction, the trial court is “going back” and doing it all over again ab initio and has the discretion, within constitutional bounds, to do anything that it could have done with that sentence at the time of the initial sentencing. Therefore, time spent during the period the sentence was vacated can be counted as consecutive time with another sentence if so ordered.
To hold otherwise, that is, that the time between the vacating of the order and Collins’ resentencing did not count as time served when at all times the trial court ordered that the sentences were to run concurrently, would mean that the amount of time that a defendant would serve would become dependant on when the “system” got around to reprosecuting his or her case. For example, in this case, if the “system” had brought him to trial six *1030months earlier, Collins’ maximum release date would have only been extended by two years, in and of itself raising due process concerns. Moreover, to hold otherwise would discourage prisoners from appealing, because even if they were successful oh appeal and the trial court issued a reduced sentence on resentencing, they could end up serving more time, in essence, being punished for having successfully appealed, again implicating due process rights. In North Carolina v. Pearce, 395 U.S. 711, 89 S.Ct. 2072, 23 L.Ed.2d 656 (1969),10 the United State’s Supreme Court specifically warned against such a “chilling effect” on prisoners taking appeals.11 Although that case was factually different,12 it stood for the proposition that due process of law requires that those who choose to exercise constitutional rights should not be penalized for exercising those rights.13
In this case, Collins’ case was pending on appeal before the trial court from January 7, 1991 until June 15, 1993, when Collins pled no contest and received a sentence of time served to fifteen years. Because Collins was still serving time in prison during the appeal, under Section 9760 of the Sentencing Code, he should have been credited for the time he spent in custody pending the resolution of his appeal and his new sentence. Accordingly, because the Department is required to recalculate the maximum date of sentencing giving Collins concurrent time for time served between the time his original sentence was vacated and he was resen-tenced, its preliminary objections are overruled and it has 30 days in which to file an answer to Collins’ petition for writ of mandamus.
ORDER
AND NOW, this 19th day of February, 2004, the preliminary objections filed by the Commonwealth of Pennsylvania, Department of Corrections, are overruled, and the Department has 30 days in which to file an answer to the petition for writ of mandamus filed by Tyrone Collins.
. CC8 8-093 92 (possession of a controlled substance (heroin), delivery of a controlled substance and criminal conspiracy, occurring November 9, 1987); CC88-09394 (possession of a controlled substance (heroin), delivery of a controlled substance and criminal conspiracy, occurring December 1, 1987).
. CC88-07389 (possession of a controlled substance (methadone) with intent to deliver and delivery of a controlled substance, occurring on January 22, 1988).
. CC88-09392.
. On February 16, 1995, the trial court granted Collins post-conviction relief and he was re-sentenced at CC88-09394 to time served to 15 years and at CC99-07389 to seven months to 15 years to run concurrent with the sentence at CC88-09394. Therefore, all cases now had maximum sentences of 15 years, rendering a new aggregate maximum date of August 24, 2003.
. Collins was apparently paroled and then had his parole revoked. Twenty-seven days of delinquent time were added to his maximum release date, bringing his maximum release date to February 28, 2006.
. A writ of mandamus is "an extraordinary remedy which compels official performance of a ministerial act or mandatory duty, as opposed to a discretionary act. The purpose of mandamus is not to establish legal rights, but to enforce those rights already established beyond peradventure.” Africa v. Horn, 701 A.2d 273, 275 (Pa.Cmwlth.1997). Because the sentence imposed by the court involves a question of law and involves no discretion on the part of the Department, a writ of mandamus will lie to compel the Department to properly compute a prisoner's prison sentence. Saunders v. Commonwealth, 749 A.2d 553 (Pa.Cmwlth.2000); Doxsey v. Commonwealth, 674 A.2d 1173 (Pa.Cmwlth.1996).
. When ruling on preliminary objections, this Court shall sustain such objections and dismiss the complaint only in cases that are clear and free from doubt that the law will not permit recovery. "In ruling on a preliminary objection in the nature of a demurrer, this Court must accept as true all well-pleaded allegations in the complaint and all inferences reasonably deduced therefrom.” Pennsylvania Chiropractic Federation v. Foster, 136 Pa.Cmwlth. 465, 583 A.2d 844, 847 (1990). A demurrer will not be sustained unless the face of the complaint shows that the law will not permit recovery, and any doubts should be resolved against sustaining the demurrer. Stone and Edwards Insurance v. Department of Insurance, 151 Pa.Cmwlth. 266, 616 A.2d 1060 (1992), affirmed, 538 Pa. 276, 648 A.2d 304 (1994).
. 42 Pa.C.S. § 9760 governs the computation of credit for time served. It states:
After reviewing the information submitted under section 9737 (relating to report of *1029outstanding charges and sentences) the court shall give credit as follows:
(1) Credit against the maximum term and any minimum term shall be given to the defendant for all time spent in custody as a result of the criminal charge for which a prison sentence is imposed or as a result of the conduct on which such a charge is based. Credit shall include credit for time spent in custody prior to trial, during trial, pending sentence, and pending the resolution of an appeal.
(2) Credit against the maximum term and any minimum term shall be given to the defendant for all time spent in custody under a prior sentence if he is later reprose-cuted and resentenced for the same offense or for another offense based on the same act or acts. This shall include credit in accordance with paragraph (1) of this section for all time spent in custody as a result of both the original charge and any subsequent charge for the same offense or for another offense based on the same act or acts.
(3) If the defendant is serving multiple sentences, and if one of the sentences is set aside as the result of direct or collateral attack, credit against the maximum and any minimum term of the remaining sentences shall be given for all time served in relation to the sentence set aside since the commission of the offenses on which the sentences were based.
(4)If the defendant is arrested on one charge and later prosecuted on another charge growing out of an act or acts that occurred prior to his arrest, credit against the maximum term and any minimum term of any sentence resulting from such prosecution shall be given for all time spent in custody under the former charge that has not been credited against another sentence.
. All of the cases cited by the Department involve questions of crediting time before a defendant began serving his or her sentence and the trial court was attempting to give credit for that time previously served. See Fajohn v. Commonwealth, 547 Pa. 649, 692 A.2d 1067 (1997); Taglienti v. Department of Corrections, 806 A.2d 988 (Pa.Cmwlth.2002); Bright v. Pennsylvania Board of Probation and Parole, 831 A,2d 775 (Pa.Cmwlth.2003).
. Pearce was overruled, in part on other grounds in Alabama v. Smith, 490 U.S. 794, 109 S.Ct. 2201, 104 L.Ed.2d 865 (1989).
. Pennsylvania’s constitutional analysis of double jeopardy, right of appeal, due process and equal protection mirrors the federal approach. See Commonwealth v. Sattazahn, 563 Pa. 533, 763 A.2d 359 (2000), affirmed by Sattazahn v. Pennsylvania, 537 U.S. 101, 123 S.Ct. 732, 154 L.Ed.2d 588 (2003).
. Pearce actually involved two separate appeals. In each appeal, the defendant was convicted of a crime and sentenced to a prison term; the original conviction was set aside in a post-conviction proceeding for constitutional error several years later, and on retrial, the defendant was again convicted and sentenced. In one case, the sentence, when added to the time the defendant had served, amounted to a longer total sentence than that originally imposed, and in the other case, the defendant received a longer sentence, with no credit being given for time already served. In Pearce, it was the trial court that had increased the sentence, where, as in this case, the Department’s calculations result in the increased maximum time Collins was to spend incarcerated.
.We note that the Court has since stated that there are times when defendants may be reconvicted and resentenced to a longer period of time, if it is warranted. See Smith, 490 U.S. 794, 109 S.Ct. 2201, 104 L.Ed.2d 865; Texas v. McCullough, 475 U.S. 134, 106 S.Ct. 976, 89 L.Ed.2d 104 (1986). However, the facts of this case do not represent one of those times, as Collins was resentenced to the same maximum amount of service, 15 years. The problem in this case is that the Department has calculated that sentence, which was to be served concurrently with the first sentence, in a way that Collins spends more time incarcerated than the sentencing judge intended.