Opinion by
Senior Judge Kalish,Joseph Graham, Angela Graham, and Deborah White, (appellants) appeal from an order of the Court of Common Pleas of Philadelphia County sustaining the preliminary objections in the nature of a demurrer of the City of Philadelphia. We vacate and remand.
In a complaint in trespass, appellants allege that they were injured while passengers on a trolley proceeding on Girard Avenue in the City of Philadelphia, when the trolley struck a loose metal beam causing the trolley to collide with a car.
Appellants allege possible liability either of the City of Philadelphia, the Southeastern Pennsylvania Transportation Authority (SEPTA), or the Pennsylvania Department of Transportation (DOT), on the theory that they were responsible for the dangerous condition on Girard Avenue.
The City filed preliminary objections in the nature of a demurrer contending that Girard Avenue is a state highway and that the City had no duty to maintain the roadway or tracks, and therefore, it was SEPTA’s respon*235sibility. The City also contended that it was immune under section 8541 of the Judicial Code, 42 Pa. C. S. §8541. It is disputed that Girard Avenue is a state highway.
The trial judge sustained the preliminary objections holding that the City had no duty to maintain the roadway or trolley tracks at the accident site, and that it was the duty of SEPTA. In view of the trial courts statement that it was the duty of SEPTA to maintain the area, SEPTA filed a brief in support of its position that the defect which caused the derailment is the responsibility of the Commonwealth of Pennsylvania, and not SEPTA.
A preliminary objection in the nature of a demurrer cannot be sustained unless the law says with certainty that no recovery is possible. If any theory of law will support the claim, a dismissal of the complaint is improper. Cianfrani v. State Employees’ Retirement Board, 505 Pa. 294, 479 A.2d 468 (1984). A complaint should be dismissed only in clear cases, and the court may not sustain a demurrer that would put an end to the controversy as it applies to the City, without giving the appellants an opportunity to file an amended complaint where the complaint can be cured by amendment. Del Turco v. Peoples Home Savings Assoc., 329 Pa. Superior Ct. 258, 478 A.2d 456 (1984).
Section 407 of the State Highway Law, Act of June 1, 1945, EL. 1242, as amended, 36 ES. §670-407, provides that the Commonwealth of Pennsylvania is responsible to keep the state highway free from “holes, ruts, sticks, loose stones, or other impediments of any kind, which tend to interfere with free and easy travel.” Section 408 of the State Highway Law, 36 ES. §670-408, provides that for the purposes of maintenance and repair, the State may enter into a contract with any City to repair and maintain any state highway.
*236As to immunity of the local governmental unit, section 8542(b) of the Judicial Code, 42 Pa. C. S. §8542(b), sets forth exceptions to governmental immunity. The pertinent section provides:
(b) Acts which may impose liability.—The following acts by a local agency or any of its employees may result in the imposition of liability on a local agency:
(6) Streets.—
(ii) a dangerous condition of streets owned or under the jurisdiction of Commonwealth agencies, if all the following conditions are met:
(A) The local agency has entered into a written contract with a Commonwealth agency for the maintenance and repair by the local agency of such streets and the contract either:
(i) had not expired or been otherwise terminated prior to the occurrence of the injury; or
(ii) if expired, contained a provision that expressly established local agency responsibility beyond the term of the contract for injuries arising out of the local agency’s work.
(B) The injury and dangerous condition were directly caused by the negligent performance of its duties under such contract.
Section 8501 of the Judicial Code, 42 Pa. C. S. §8501, defines a local agency as, “[a] government unit other than the Commonwealth government.”
A city can waive its immunity by agreement. Ludwin v. Port Authority Transit Corp., 102 Pa. Commonwealth Ct. 36, 517 A.2d 1006 (1986). Here, factually it appears uncertain as to what the situation was with reference to the street involved, and whose duty it was to maintain the area involved. Since the appellants have pleaded suffi*237cient facts which could result in the City being held liable, the trial courts order sustaining the preliminary objections was inappropriate.
Accordingly, we vacate and remand for further proceedings consistent with this opinion.
Order
NOW, April 18, 1989, the order of the Court of Common Pleas of Philadelphia County, No. 55 March Term 1988, is vacated, and the case is remanded for proceedings consistent with this opinion.
Jurisdiction relinquished.