OPINION OF THE COURT
FLAHERTY, Justice.Appellants, Concept Planners & Designers and Aetna Casualty Company, request that we reverse the order of the Commonwealth Court and issue an order dismissing the petitions of Eddie Smith requesting modification and reinstatement of benefits and attorney’s fees and penalties under The Pennsylvania Workmen’s Compensation Act (Act).1
Claimant was employed as a carpenter by Concept Planners & Designers when he sustained a work-related injury to his lower back. Claimant received compensation for a closed period from May 14, 1973 until September 12, 1973, when he returned to work. Claimant again received total disability benefits beginning March 25,1976.
Benefits ended on September 2,1980 when an automatic supersedeas was entered because appellants filed a termination petition. At a hearing on the termination petition before a referee on March 3, 1981, claimant appeared in person and was not represented by counsel. The termination petition was amended to a modification petition and the parties agreed that claimant’s total benefits would be reduced, based on a loss in earning power flowing from the percentage of disability resulting from the work-related injury. By an order dated March 12,1981, the referee ordered the appellants to pay partial permanent benefits for a 500 week period at the rate of $50.00 per week, said payment to be commuted to a lump sum of $25,000 running from September 1, 1980 onward. Neither party appealed.
Claimant filed a pro se reinstatement petition in which he alleged that his disability had changed from partial to total as of August 7, 1990. With assistance of counsel, claimant filed another reinstatement petition on September 24, 1990 where he alleged that his total disability payments should be reinstated as of April 9,1981. Appellants filed a termination petition on December 17, 1990, asserting that benefits should be terminated because claimant refused to undergo reasonable medical treatment, ie., surgery.2
The referee found that claimant’s disability had recurred and reinstated claimant’s benefits as of December 12, 1990. The referee also found that claimant was not totally disabled as of an earlier date and, therefore, denied claimant’s petition for reinstatement dating back to 1981. The referee also denied appellants’ termination petition but found that appellants had a reasonable basis for filing the termination petition and denied claimant’s request for counsel fees.
Both parties appealed to the Workmen’s Compensation Appeal Board. Claimant argued he should have been reinstated as of an earlier date and awarded his attorney’s fees. Employer argued there was insufficient evidence to establish claimant’s condition had worsened and the referee erred in denying the termination petition. The board, without taking additional evidence, reversed the referee’s reinstatement of benefits, reasoning there was not substantial evidence in the record to support the referee’s finding that claimant’s total disability recurred as of December 12, 1990. The board affirmed the *1148referee’s denial of the employer’s termination petition and of claimant’s request for counsel fees.
Commonwealth Court reversed and remanded, reinstating total disability benefits and awarding attorney’s fees. Eddie Smith v. W.C.A.B. (Concept Planners & Designers and Aetna Casualty), No. 608 C.D.1993 (Slip Opinion at 5, Nov. 23, 1993). This appeal followed.
Appellants argue, for the first time in this case, that claimant’s petitions for modification and reinstatement are barred by the statute of limitations since claimant failed to file the petitions within three years of the date of his last receipt of compensation benefits as required by section 413(a) of the Act. Pa.Stat.Ann. tit. 77, § 772 (1974) (“section 413(a)”).3 Appellants cite as authority Mason v. W.C.A.B. (Acme Markets), 156 Pa. Cmwlth. 10, 625 A.2d 1271 (1992). There, Mason filed a petition seeking reinstatement of temporary total disability benefits following receipt of a lump-sum payment representing a commutation of disability benefits. The petition was filed after three years had elapsed but before the expiration of the commutation period which the lump sum payment represented. The court ruled the statute of limitations began to run as of the date the lump sum payment is received and not at the end of the commutation period which the lump sum payment represents and, therefore, the petition was time barred. Id. at 13, 625 A.2d at 1272-73.4 Appellants argue Mason applies to bar claimant’s petitions that were filed in 1990, nine years after his last receipt of compensation in 1981, but within the ten years represented by the commutation.
Claimant argues appellants have waived the issue of the statute of limitations presented by Mason because they failed to raise it in a timely fashion. Claimant contends that since Mason was announced over a year before Commonwealth Court issued its order in claimant’s case, appellants could have raised the issue in Commonwealth Court.
Appellants contend the statute of limitations under section 413(a) is a statute of repose which can be raised at any time because it involves a jurisdictional question. They cite as authority McDevitt v. W.C.A.B. (Ron Davison Chevrolet), 106 Pa.Cmwlth. 207, 525 A.2d 1252 (1987), petition for allowance of appeal dismissed as improvidently granted, 520 Pa. 119, 552 A.2d 1048 (1989). There, the court held the three-year limitations period in section 315 of the Act5 (“section 315”) for the filing of a petition for compensation for personal injuries was a statute of repose because it was jurisdictional in nature and, thus, could not be waived. Id. at 211, 525 A.2d 1252. The court recognized that where a statute of limitations operates to extinguish a remedy, it can properly be pled as an affirmative defense and, thus, can be waived. Id. Appellants argue that since section 413(a) contains a similar three-year limitations period, it is likewise jurisdictional in nature and, thus, can be raised at any time in the proceedings so that Mason applies to bar claimant’s petitions.
While sections 315 and 413(a) contain similar statutes of limitations, each functions in a different context. Section 315 functions where no prior legal action has commenced; however, section 413(a) functions as a means to halt further legal action following prior legal action and the award of a remedy. Since section 413(a) operates to cut off future remedies in a case with a history rather than to halt initiation of a new case with no history, it operates in a way *1149that, practically speaking, extinguishes a remedy rather than a right. We therefore hold the defense of section 413(a) is one which, if not raised at the appropriate time, can be waived.6 Here, since appellant failed to raise the issue presented by Mason in a timely fashion, the issue is waived.7
Appellants then argue Commonwealth Court erred in concluding they had no reasonable basis to file a petition for termination of compensation on December 13, 1990. Title 77, section 531(4) of Pennsylvania Statutes provides that if a claimant refuses reasonable medical services, the claimant forfeits all rights to compensation for any injury or any increase in the claimant’s incapability shown to have resulted from that refusal. Appellants argued below that claimant’s refusal of reasonable medical care in the form of surgery resulted in a forfeiture of benefits. In cases involving petitions for termination which are resolved in favor of the employee, an award of attorney’s fees is usually granted unless the employer established on the record that a reasonable basis for the contest exists. Majesky v. W.C.A.B. (Transit America, Inc.), 141 Pa.Cmwlth. 398, 402, 595 A.2d 761, 763 (1991).
The critical issue is whether substantial evidence of record existed to support the referee’s finding that appellants had a reasonable basis to contest claimant’s actions and thus to avoid responsibility for claimant’s attorney’s fees. Under agency law, a reviewing court shall affirm the adjudication unless any finding made by the agency and necessary to support its adjudication is not supported by substantial evidence of record. Estate of McGovern v. State Employees’ Re-tirement Board, 512 Pa. 377, 385, 517 A.2d 523, 527 (1986). The referee is the ultimate fact finder and it is his role to assess the credibility of the witnesses. Bethenergy Mines, Inc. v. W.C.A.B. (Skirpan), 531 Pa. 287, 292-93, 612 A.2d 434, 436-37 (1992).
In claimant’s case, the record reflects substantial evidence of record to support the referee’s finding that appellants had a reasonable basis to contest claimant’s actions by filing the termination petition on December 13, 1990. Claimant’s own doctor testified on December 12, 1990 that surgery was a reasonable course of medical treatment and one which was recommended to claimant. Commonwealth Court focused on the deposition testimony of a doctor who examined claimant four months after the termination petition was filed. It ruled that appellants could not use this post hoc examination to establish a reasonable basis for the filing of the termination petition.
Commonwealth Court erred by substitute ing its judgment for that of the factfinder. Its proper role was to examine the record to determine whether substantial evidence of record existed to support the referee’s decision. Since the record reflects substantial evidence to support the referee’s conclusion that appellants had a reasonable basis to file the termination petition, the decision of Commonwealth Court concerning attorney’s fees is reversed. In all other respects, its decision is affirmed.
Order of Commonwealth Court reversed as to attorney’s fees and affirmed in all other respects.
*1150NIX, C.J., concurs in the result.
CASTILLE, J., files a concurring opinion.
. Act of June 2, 1915, Pub.L.No. 736, as amended, Pa.Stat.Ann. tit. 77, §§ 1-1031.
. The petitions were consolidated for a hearing before the referee.
. Section 413(a) provides that a petition for modification or reinstatement must be filed "within three years after the date of the most recent payment of compensation.... ”
. In Mason, the issue of the statute of limitations was addressed by the referee and the employer was the successful party throughout the proceedings.
.Pa.Stat.Ann. tit. 77, § 602 (1974). Section 315 provides that in cases of personal injury, "all claims for compensation shall be forever barred, unless, within three years after the injury, the parties shall have agreed upon the compensation payable under this article; or unless within three years after the injury, one of the parties shall have filed a petition as provided in article four hereof.” Id.
. This conclusion serves the purpose of the waiver rule. That purpose is to ensure that the tribunal with initial jurisdiction is presented with all cognizable issues so that the "integrity, efficiency, and orderly administration of the workmen’s compensation scheme of redress for work-related injury” is preserved. See DeMarco v. Jones & Laughlin Steel Corporation, 513 Pa. 526, 530-32, 522 A.2d 26, 29 (1987) where this court ruled that an employer's failure to raise the defense of res judicata before the referee constituted a waiver of that issue. Such purpose is not served where a party to proceedings that have spanned years can raise an issue late in the appellate process, long after it could have been raised and after much time and resources of the parties and the court have been expended, and where no record, especially the considered reasoning of the lower tribunal, has been developed.
. Claimant also argues that appellants are es-topped from raising the limitations issue because they fraudulently misled claimant into believing that he had ten years of benefits, which included social security benefits, and, therefore, ten years before he had to do anything to preserve his rights. No lower court or other tribunal has had an opportunity to consider the issue. In light of the discussion above, we need not address this matter.