Opinion by
Mr. Justice Roberts,This appeal involves a challenge to the validity of certain pension plans adopted by the City of Sharon for the benefit of retiring police and firemen. Four cases were consolidated on this appeal, and, although each must ultimately be considered on its own particular factual configuration, all raise the same basic issue upon which the resolution of the other issues involved depends: were the ordinances establishing the pension plans in conformity with their enabling statutes?
Since it is beyond dispute that a municipality has no power to enact ordinances except as authorized by the Legislature, and that any ordinance not in conformity with its enabling statute is void, Allentown Softool Dist. Mercantile Tax Case, 370 Pa. 161, 87 A. 2d 480 (1952); Genkinger v. New Castle, 368 Pa. 547, 84 A. 2d 303 (1951); Murray v. Philadelphia, 364 Pa. 157, 71 A. 2d 280 (1950); Kline v. Harrisburg, 362 Pa. 438, 68 A. 2d 182 (1949), it is clear that if the challenged ordinances are determined not to conform in any material respect with their enabling legislation, they must be declared invalid. Cf. Allentown School Dist. Mercantile Tax Case, supra.
The statutes directing municipalities of the third class to adopt pension plans for police1 and firemen2 set forth in detail the requirements for the establishment and operation of such funds. However, in our view the present ordinances so deviate from the letter and spirit of the enabling legislation as to render unnecessary a section by section analysis and comparison in order to ascertain whether the challenged plans are in conflict with or unauthorized by the enabling acts. *634As stated by tbe court below, “it is inherent in tbe concept of any retirement plan that whatever tbe amount of monthly retirement pay or delayed compensation may be, it is to be continued during tbe entire lifetime of tbe recipient.”3 Tbe plans here in dispute do not provide for lifetime payments, and, for that reason, cannot be said to provide for tbe system of retirement benefits contemplated by tbe Legislature.
Under tbe city’s plans,4 a monthly deduction is made from tbe wages of each participating member and credited, along with a contribution from tbe city, to an individual account maintained for that person. Although tbe funds are treated as one for investment purposes during tbe period of a member’s employment, upon retirement, that portion of tbe fund attributable to tbe retiree is removed from tbe fund and a new, segregated account established. From that point, tbe retiree no longer shares in tbe income received by the general fund.
Tbe retiring member selects an amount which be desires to receive monthly from bis account, with tbe limitation that tbe amount chosen may be no less than $50 nor more than one-half bis salary at retirement. If these monthly payments exhaust bis account during bis lifetime, no further benefits under tbe plans can be *635received. If a member dies, either before retirement or before exhausting his account, the amount remaining therein is paid in a lump sum to his widow, minor children or estate.5
No extended discussion is required to demonstrate the weakness of this plan. The system of delayed compensation as contemplated by the Legislature is designed “to aid employees who have served a long period of time in public employment and have reached an age where through decreased earning power because of impairment of mental or bodily vigor, they are compelled to separate themselves from active service.” Retirement Board v. McGovern, 316 Pa. 161, 164, 174 Atl. 400, 402 (1934). The plans adopted by the City of Sharon would abandon the retiree during the very period when assistance was most needed and clearly intended by the Legislature to be forthcoming. In the absence of a provision for lifetime benefits for the retiree, we are unable to conclude that the plans here adopted conform to the legislative intent as embodied in the enabling acts.
Moreover, the limitation upon the benefits to which the retiree is entitled is so interrelated to the other features of the plans, such as permitting the retiree to select the amount of his retirement pay, and the payment of the balance of a retiree’s segregated account to his family upon his death, that we are unable to do other than hold that both ordinances are invalid in their entirety.6
*636We are therefore confronted with the tasks of determining the effect of this invalidation upon the rights of the respective claimants whose actions have been consolidated on this appeal.
I
Taylor v. Abernathy (No. 185)
Lawrence Taylor is a former Sharon police officer who retired in 1956 after 20 years continuous service. At that time, his portion of the general pension fund, amounting to $14,154.32, was transferred to a separate account established in his individual name. Mr. Taylor chose to receive the sum of $180 per month from his account. These payments continued until January 1964, at which time he was notified that no funds remained in his account and that he would thus receive no further pension payments. Taylor was then 70 years of age.
A complaint in mandamus was filed by Taylor to compel the city council of Sharon to enact a valid police pension ordinance providing for lifetime benefits and to resume his monthly payments of $180, retroactive to January 1, 1964. Following a hearing, the court below entered the following order: “And Now, March 29, 1965, it is ordered that the Council of the City of Sharon shall proceed forthwith to amend Ordi*637nance No. 66-52 in such a manner as to comply with the mandatory requirements of the Police Pension Fund Provisions of the Third-Class City Code. Council is to use its own discretion as to those portions which are discretionary, hut providing therein that officers who shall have retired on or before March 29, 1965, shall continue to receive the monthly retirement pay at the rate designated by them at the time of their retirement until the end of their lives, effective from the date when the said payments were discontinued, December, 1963, and, in the case of any such officers whose pay has been discontinued, such arrearage in payment shall be, as well, made to them forthwith, to be computed from the date that it was discontinued.”7
We are in complete agreement with the determination of the court below that the enabling act directing the establishment of a police pension fund is mandatory. Commonwealth ex rel. Coghlan v. Beaver Falls Council, 355 Pa. 164, 49 A. 2d 365 (1946). This point is not disputed by the city on appeal. It therefore follows that the city is under a duty to adopt a police pension plan, and that the court below correctly ordered the city henceforth to comply with the enabling statute. However, the issue of the amount of monthly income to which appellee Taylor is and hereafter will be entitled is not so easy to resolve.
While the enabling act is mandatory in that it directs cities of the third class to adopt a police pension plan, it neither directs nor permits such cities to allow retirees to select the amount of their monthly benefits. Such a feature, as previously indicated, is dependent upon a plan which contains a limitation upon the total amount of benefits to which the retiree could be entitled. Otherwise, such a feature would render a pension plan actuarially unsound. And while a formula *638is provided by tbe enabling act wbicb limits tbe discretion of tbe local governing bodies in determining tbe amount of monthly pay a retiree will receive,8 tbe function of making that determination nevertheless remains discretionary within those boundaries. Tbe court below, therefore, erred in directing tbe city council to pay benefits to Taylor and others similarly situated on tbe basis of tbe benefits selected under tbe old plan.
However, while mandamus may not compel a body vested with discretionary power to exercise that power in a certain manner or to arrive at a certain decision, mandamus will lie to compel a body so empowered to exercise its discretion within tbe prescribed limits. Hotel Casey Co. v. Ross, 348 Pa. 573, 583, 584, 23 A. 2d 737, 742 (1942); Commonwealth ex rel. Kelley v. Pommer, 330 Pa. 421, 439, 440, 199 Atl. 485, 492 (1938). Thus, the council may be compelled to provide for retirees under tbe enabling act on tbe basis of tbe guidelines therein set forth.
It is clear, therefore, that if Taylor and others similarly situated are to be included in tbe new pension plan tbe city has been ordered to adopt, their participation may only be on tbe basis of a proportionate share as determined by tbe council under the formula provided by tbe enabling act. Tbe question then remains as to their right to be so included.
*639From the date the act directing cities of the third class to establish a pension plan for retiring policemen became the law of this Commonwealth, the City of Sharon was under a duty to enact an ordinance in compliance therewith. It would therefore follow that the city should be ordered to comply with the enabling act retroactively. Commonwealth ex rel. Coghlan v. Beaver Falls Council, 355 Pa. 164, 49 A. 2d 365 (1946). However, while the logic of this proposition has not been questioned, the practicalities of the situation have, in the past, cautioned this Court against the retrospective imposition of obligations which might have been incurred had mandatory legislation been followed. Commonwealth ex rel. Coghlan v. Beaver Falls Council, supra. Thus, it has been held that retroactive compliance with a mandatory act will not be compelled where the practical difficulties such compliance would engender would cause more inequity than the harm sought to be remedied. Commonwealth ex rel. Coghlan v. Berner Falls Council, supra. Under such circumstances, this Court has sought the most propitious means of achieving future compliance with the legislative mandate while, at the same time, not unduly prejudicing the rights of those who would have benefited had the local governing body promptly complied with the statute.
Applying this principle to the instant case, we direct that Taylor and others similarly situated shall be included in the new pension plan to be adopted, on the same basis as if the new ordinance had been in effect at the time they joined the police department of the City of Sharon. In this way, the more than 20 years which Taylor devoted to the City of Sharon will not be ignored, and his salary and contribution therefrom will be utilized in the determination of the benefits to which he will be entitled. However, the city shall only be liable for such payments retroactive to January 1964, the date that payments were discontinued under *640the invalid ordinance. In the event that it is determined that Taylor will be entitled to monthly benefits under the new plan of a lesser amount than he had been receiving under the old plan, the city will be permitted to compensate for this factor by calculating the amount of the excess received by him under the old plan and reducing his benefits under the new plan by a like amount, over a period of time to be determined by appropriate actuarial reference.
Accordingly, the order entered below in No. 185, Taylor v. Abernathy, is affirmed as modified.9
II
The Merchants and Manufacturers National Bank of Sharon v. Police Pension Fund Commission (No. 187)
This is a mandamus action instituted by the Estate of Mildred S. Miller, a former police matron, seeking to compel the Commission to pay to it the balance remaining in Mrs. Miller’s account at thé time of her death. The court below, relying on Bausewme v. Philadelphia Police Pension Fund Association, 337 Pa. 267, 10 A. 2d 446 (1939) and Commonwealth v. Walton, 182 Pa. 373, 38 Atl. 790 (1897), held that even though the ordinance establishing the police pension fund did not conform to the requirements of the enabling statute, it nevertheless created enforceable rights in the estate of the deceased. It therefore ordered the Sharon Police Pension Fund to pay to the estate the balance remaining in the Miller account at the time of her decease.
*641However, neither Bausewine nor Walton stand for the proposition that a municipality may create enforceable contractual rights pursuant to an invalid ordinance. In Walton, it was held that the City of Philadelphia had the power to appropriate money to a private corporation created for the legitimate purpose of establishing a police pension system and that the private corporation was, for the purpose of distribution of funds appropriated for the retirement pay of the police department of the city, an agency of the municipal government. In Bausewine, it was held that the City of Philadelphia, being under a mandatory obligation to establish a pension system for its retired policemen, could discharge that duty by making annual contributions to a private corporation created for that purpose. In neither case was it contended that the substantive provisions of the police pension plan there involved deviated in any material respect from the plan contemplated by the enabling act.
In the present case, the system devised for the payment of retirement benefits to members of the Sharon police department did not conform with the intent of the enabling legislation, and, therefore, unlike the plans in Bausewine and Walton, could not be sustained as being in substantial compliance with the direction of the Legislature. We are thus compelled to conclude that the Miller Estate may not prevail on the basis of a contractual right created under the invalid police pension ordinance.
Moreover, at the time the enabling act was first enacted by the Legislature, no provision was made for the inclusion of the family of deceased retirees. Act of June 23, 1931, P. L. 932. In a 1959 amendment to the enabling act, the Legislature permitted cities of the third class to provide for “widows of retired members if council so elects.” Act of July 27, 1959, P. L. 569. It was not until the most recent amendment to the en*642abling act that the Legislature made it mandatory upon cities of the third class to include widows of deceased retirees within the coverage of their pension plans. Act of September 1, 1965, P. L. 462, 53 P.S. §39303 (Supp. 1965).
From this, it can be seen that the City of Sharon violated no duty to the family10 of Mrs. Miller by failing to enact a pension plan in compliance with the enabling act, even though, in the future, the city will be under a duty to include designated family members of retirees within its pension system.11
However, the fact remains that Mrs. Miller served for a period in excess of 20 years in the police department of the City of Sharon, in the good faith belief that she would receive retirement benefits during her later years, and that after her death, her family would be the recipient of the balance of her account. We are unwilling to permit the city to thwart her justifiable expectations after she has passed away. We are especially reluctant in such a case as present, since the city’s own mistake was responsible for the creation of those expectations. Had the city adopted a proper *643pension plan ab initio, it is entirely possible that Mrs. Miller would have made other arrangements to provide for her family upon her death.
Under these circumstances, the city may not deprive Mrs. Miller’s estate of the money remaining in her account, most of which she contributed herself from her salary. Although the estate has no contractual right to compel the city to pay the money over to it, as between the estate and the city, we believe that the estate has demonstrated the superior right to the money remaining in the Miller account. Therefore, in order to return the parties to a reasonable approximation of where they might have been had the city not adopted an invalid pension plan, we direct the city to pay the balance of the money remaining in the account of Mildred S. Miller to her estate.
Accordingly, the order entered by the court below in No. 187, The Merchants and Manufacturers National Bank of Sharon v. Police Pension Fund Commission, is affirmed.
Ill
The City of Sharon and the Police Pension Fund Commission v. Taylor (Nos. 188, 189)
This is an action instituted by the City of Sharon and by the Police Pension Fund Commission seeking a declaratory judgment. The defendants in the action, in addition to the administrator of the Miller Estate, plaintiff in No. 187, and Lawrence Taylor, plaintiff in No. 185, include the present employees of the Sharon Police Department who are members of the invalid pension plan.
The city, recognizing the invalidity of its present pension plan, has announced its intention to adopt a new plan, providing for lifetime retirement benefits in *644compliance with the enabling act. However, the invalid plan now has approximately $600,000 in assets. If this money may be utilized by the city to fund a new pension plan, the city council will be able to adopt a pension system providing for larger lifetime benefits. If, on the other hand, a substantial portion of the present fund must be held in segregated accounts for the benefit of those who contributed thereto, the lifetime retirement benefits under the new plan will be substantially lower.
The present members of the Sharon police force, some of whom have qualified for retirement and the resulting pension under the old plan,12 contend that their right to participate in the fund under the terms and conditions contained in the old plan is a contractual right which cannot be altered without their consent. In support of this position, they rely upon Wright v. Allegheny County Retirement Board, 390 Pa. 75, 79, 134 A. 2d 231, 233 (1957), which held that “a public employee has a contract right to continued membership in a retirement fund, under the same rules and regulations prevailing at the time of his employment, which may not be qualified or altered by subsequent legislative enactment.” (Citation omitted.)
However, this contention is answered by the reasoning set forth in Miller Estate. Unlike the situation in Wright, and the other cases cited therein, no contractual rights came into existence under the invalid plan here involved. While it is true that a contractual right to continued membership arises at the time of employment, when a valid pension plan then exists, it does not follow that a contractual right also arises when a municipality acts in an unauthorized and invalid man*645ner, such as in the present case. Thus, the cases relied upon are inapposite.
This, however, is not in itself dispositive. In Miller Estate, we invoked our Kings Bench power in order to protect the good faith expectation of the contributing member. In that case, we felt that there was no other means of assuring the fulfillment of the expectation which the city had mistakenly created.
In the situation involving living members of the Sharon Police Department, regardless of whether they have retired, qualified for retirement under the invalid plan, or not yet met the conditions for retirement imposed thereunder, the expectations created under the invalid pension plan can be protected in a manner more consistent with the interests of all involved.13 The city has been ordered to adopt a valid pension plan in compliance with the enabling act. Thus, the living members of the police department, including those who have already retired, will be included within the new plan and entitled to the benefits provided thereunder. See Part I, supra. And, as previously indicated, since the new pension plan will have to provide for widows and children of deceased retirees, even the expectation of the members that their families will be provided for will be fulfilled.14
Moreover, for the reasons stated in Taylor, in order to assure that the city does not ignore the years of service which the members of the police department *646have given, we direct that the present members shall be included within the new plan as if that plan had been in existence at the time they commenced their employment, and that their retirement benefits be computed on the basis of the sum to which they would be now entitled had they served the same number of years at the same salary under the new plan as they have served under the invalid plan.
We therefore hold that the city may utilize the balance remaining in the invalid pension plan to fund its new pension system, and that the retirement benefits payable thereunder shall be computed as set forth above.
Accordingly, the order entered below in Nos. 188, 189, The City of Sharon and the Police Pension Fund Commission v. Taylor, is affirmed as modified.
IY
King v. Firemen’s Pension Fund of Sharon (No. 186)
This is an action of mandamus instituted by Ethel F. King, widow of Arthur S. King, a former member of the Sharon Fire Department, to compel the Firemen’s Pension Fund to pay to her the balance remaining in the account of her husband at the time of his death.
Our review establishes that the issue here presented is identical to that resolved in Part II, supra, and that that case is dispositive.15 The order entered below in *647No. 186, King v. Firemen’s Pension Fund of Sharon, is affirmed.
The orders of the court below in Numbers 185, 188 and 189 are affirmed as herein modified.
The orders of the court below in Numbers 186 and 187 are affirmed.
Mr. Chief Justice Bell dissents.Act of June 23, 1931, P. U. 932, as amended, 53 P.S. §§39301-39308 (Supp. 1965).
Act of June 23, 1931, P. L. 932, as amended, 53 P.S. §§39320-89327 (Supp. 1965).
Taylor v. Abernathy, Court of Common Pleas of Mercer County, March 29, 1965. (Unreported.)
The City of Sharon first adopted a police pension plan on May 14, 1946, Sharon, Pa., Ordinance No. 1105, May 14, 1946, which ordinance was subsequently repealed on July 22, 1952, and “reinstated” on December 23, 1952. Sharon, Pa., Ordinance No. 66-52, December 23, 1952. This ordinance, as amended, remains in effect. A fireman’s pension plan was established by the city in December 1948, Sharon, Pa., Ordinance No. 1221, December 14, 1948, and abolished on July 22, 1952. Dater that same year, the city “reinstated” the fireman’s pension plan as if Ordinance No. 1221 had never been abolished. Sharon, Pa., Ordinance No. 67-52, December 23, 1952. This latter ordinance, as amended, remains in effect.
Although the ordinances establishing the police pension plan and the fireman’s pension plan are not identical, both contain the provisions herein described.
It is urged that the plans adopted by the city, although not in conformity with the enabling acts, should be sustained as being a legitimate exercise of the city’s police power. However, under The Third Glass City Code, Act of June 23, 1931, P. L. 932, as amended, 53 P.S. §37403(60), cities of the third class are empow*636ered “to make and adopt . . . such ordinances . . . not inconsistent with . . . laws of this Commonwealth, as may be expedient or necessary for the proper management, care and control of the city . . . and the maintenance of the . . . good government . . . and welfare of the city . . . .” (Emphasis supplied.) It having been determined that the ordinances here involved are inconsistent with the “laws of this Commonwealth”, we need not reach the question of whether the plans could be sustained under this general police power in the absence of express statutory direction by the Legislature.
Taylor v. Abernathy, Court of Common Pleas of Mercer County, March. 29, 1965.
The Act provides: “The basis of the apportionment of the pension shall be determined by the rate of the monthly pay of the member at the date of . . . retirement, or the highest average annual salary which the member received during any five years of service preceding . . . retirement, whichever is the higher, and . . . shall not in any case exceed in any year one-half the annual pay of such member computed at such monthly or average rate, whichever is the higher.” Act of June 23, 1931, P. L. 932, as amended, 53 P.S. §39303 (Supp. 1965). It is further provided that all retirement benefits “shall be in conformity with a uniform scale . . . .” Act of June 23, 1931, P. L. 932, as amended, 53 P.S. §39301 (Supp. 1965). Moreover, it is undisputed that the city is under a duty to make the plan aetuarially sound.
In addition to our Kings Bench power, this Court, by statute, is empowered “in all cases to affirm, reverse, amend or modify a judgment, order or decree appealed from, and to enter such judgment, order or decree in the ease as . . . [the Court] may deem proper and just. . . .” Act of May 20, 1891, P. L. 101, 12 P.S. §1104.
The present action was instituted by the Merchants and Manufacturers National Bank of Sharon, Administrator of the Estate of Mildred S. Miller, deceased. The record does not reveal the familial relationship of those surviving the deceased.
The Act provides: “§39303(c). The widow of a member of the police force or a member who retires on pension who dies, or if no widow survives or if she survives and subsequently dies or remarries, then the child or children under the age of eighteen years of a member of the police force or a member who retires on pension who dies on or after the effective date of this amendment, shall, during her lifetime or so long as she does not remarry in the case of a widow or until reaching the age of eighteen years in the case of a child or children, be entitled to receive a pension calculated at the rate of fifty per centum of the pension the member was receiving or would have been receiving had he been retired at the time of his death.” Act of June 23, 1931, P. B. 932, as amended, 53 P.S. §39303(c). (Supp. 1965).
One member has already retired tinder the invalid plan, but, unlike Taylor, has not yet exhausted his portion of the general fund now segregated in his name.
It should be obvious that were the city unable to utilize the money now held under the old plan to fund the new plan to be adopted, the newer — and future — members of the police department would suffer an economic loss at the hands of the older — or presently retired — members.
In fact, that expectation will be guaranteed of fulfillment if the member is survived by his widow or minor children. Under the old plan, were the member to exhaust his account during his lifetime, his widow and children would receive nothing.
it must be noted that tbe firemen’s pension fund enabling act differs from tbe police pension fund enabling act in that, while mandatory, it provides for alternatives. Thus, the city council of Sharon may either “provide annuity contracts or establish, by ordinance, a firemen’s pension fund.” Act of June 23, 1931, P. L. 932, as amended, 53 P.S. §39320 (Supp. 1965). (Emphasis supplied.) In addition, the determination as to whether to include *647widows and children of deceased retirees is left to the discretion of the local governing body.
The Eiremen’s Pension Eund Commission contends that the city need not comply with the enabling statute, since it is therein provided that “in any case where there is an existing organization or association for the benefit of fully paid firemen, constituting and having in charge the distribution of firemen’s pension funds, no annuity contract shall be provided, nor shall any firemen’s pension funds be established under the provisions of this section unless and until the members of such organization or association, by a two-thirds vote, elect to transfer said existing fund into the pension fund required to be established by this section.” Act of June 23, 1931, P. L. 932, as amended, 53 P.S. §39320 (Supp. 1965). The Commission urges that the present fund, albeit invalid, nevertheless constitutes an “existing organization” within the meaning of the act, and that therefore approval of two-thirds of the present members is required before the city may employ the moneys held under the invalid plan to fund its new pension plan. We are unable to agree. The Act contemplated organizations existing at the time of its passage, not organizations created thereafter. Were the contention of the Commission to prevail, a city could avoid the requirements of the enabling act by simply creating an organization for the purpose of providing pension benefits for retired firemen. This was not the intention of the Legislature. This provision was included in the enabling act so as not to disrupt existing pension organizations, not to foster the creation of new ones.