
63 Cal.App.3d 867 (1976)
134 Cal. Rptr. 58
COMMONWEALTH MEMORIAL, INC., Plaintiff and Appellant,
v.
TELOPHASE SOCIETY OF AMERICA, Defendant and Respondent.
Docket No. 15937.
Court of Appeals of California, Fourth District, Division Two.
November 16, 1976.
*869 COUNSEL
Virtue & Scheck, Joseph A. Walker and Thomas M. Gieser for Plaintiff and Appellant.
Tom Sherrard for Defendant and Respondent.
OPINION
KAUFMAN, J.
(1) (See fn. 1.) Plaintiff in this unlawful detainer action appeals from an order granting defendant's motion for "nonsuit."[1]

Facts
Memorial Properties, Inc., a corporation, owned property in Anaheim operated as a cemetery and known as The Melrose Abbey. On or about February 15, 1974, upon specified rent payable over the term, Memorial leased a part of the cemetery property to The Telophase Society of America, Inc., a California corporation, (hereinafter "defendant") for a term of 30 years to be used as a crematory.
Thereafter Memorial sold the cemetery property, including that portion leased to defendant, to Commonwealth Memorial, Inc., a California corporation, (hereinafter "plaintiff"). Memorial reserved to itself, however, the lessor's rights under the lease between Memorial and defendant. The agreement between Memorial and plaintiff provided for the sale to plaintiff of "All properties, tangible or intangible, real, personal, or mixed, leaseholds, licenses, easements, profits, permits, franchises, rights-of-way, servitudes, reversions, remainders, and all other similar or dissimilar interests or estates; except that certain Lease dated February 15, 1974 showing Telophase Society of America as Lessee and any right, title or interest of Memorial in that certain Lease dated February 15, 1974 between Memorial and the Telophase Society of America. Commonwealth shall continue to recognize said Leases and *870 shall take all real property conveyed hereunder subject to said Leases; ..." (Italics added.)
On February 25, 1975, plaintiff instituted this action for unlawful detainer alleging that defendant was using the crematory unlawfully in that it failed to obtain a certificate of authority as required by the Business and Professions Code. (See Bus. & Prof. Code, §§ 9768, 9715.)
After plaintiff rested its case, the trial court granted defendant's motion for "nonsuit" (see fn. 1, ante) on the ground that plaintiff was neither defendant's landlord or successor in estate to its landlord within the contemplation of section 1161 of the Code of Civil Procedure[2] and, thus, could not maintain the statutory action for unlawful detainer.

Contentions, Discussion and Disposition
(2) Plaintiff acknowledges that it is not defendant's landlord in the customary sense but insists it is the successor in estate to Memorial. Not quite. Memorial reserved to itself in its contract with plaintiff the rights under the crematory lease, and plaintiff, therefore, has as to the crematory property only a reversionary or remainder interest following expiration of the lease.
The crucial question is what the parties intended (see Upton v. Toth, 36 Cal. App.2d 679, 686 [98 P.2d 515]), and we are persuaded as was the trial court, that the parties intended that Memorial would remain defendant's landlord.
Plaintiff places some reliance on Civil Code section 821 quoted in the margin[3] and Rosenkranz v. Pellin, 99 Cal. App.2d 650, 652-653 [222 P.2d 249], based upon that code section. Rosenkranz states the general rule: "[A] sale by a lessor of real property during an unexpired term does not *871 of itself abrogate the lease. Its effect is to grant all the rights of the original lessor to the grantee of the reversion. The grantee then becomes the landlord by operation of law and the tenant becomes a tenant of the grantee of the reversion." (Accord: Upton v. Toth, supra, 36 Cal. App.2d at p. 684.) However, Civil Code section 821 and Rosenkranz apply only in the absence of a contrary agreement of the parties. Here the purchase and sale agreement between Memorial and plaintiff expressly reserves to Memorial the landlord's rights under the lease to defendant, and plaintiff did not become defendant's landlord by operation of law.
(3) Plaintiff points to Civil Code section 826 which provides in pertinent part: "A person having an estate ... in remainder or reversion, may maintain an action for any injury done to the inheritance...." This statute does not grant a reversioner or remainderman authority to maintain an action for unlawful detainer which is governed not by Civil Code section 826 but by Code of Civil Procedure section 1159 et seq. Civil Code section 826 merely affirms the unquestioned right of a remainderman or reversioner to sue for injunction or damages for injury to his estate. (See Heilbron v. Water Ditch Co., 75 Cal. 117, 121-122 [17 P. 65].) Thus, although plaintiff may not maintain a statutory action for unlawful detainer against defendant, it is not without remedy.
Plaintiff urges that, in effect, it was nonsuited for its failure to join Memorial as a party defendant contrary to Code of Civil Procedure section 1164.[4] The simple answer is that judgment was given for defendant not because plaintiff failed to join Memorial as a party defendant but because the court concluded that plaintiff was not a real party in interest in the action for unlawful detainer.
Finally, plaintiff resorts to "a parade of the horribles." As plaintiff correctly points out, Memorial is left as defendant's landlord but has no interest in enforcing any covenant of the lease except the covenant to pay rent. Admittedly, the unique transaction between plaintiff and Memorial has that unfortunate result. Perhaps plaintiff should not have entered into such an arrangement, but it did, and we cannot rewrite the agreement for the parties. A holding that plaintiff is entitled to maintain *872 unlawful detainer, however, would be productive of even greater mischief. Contrary to the obvious intent of the parties, plaintiff would be able to terminate the lease and thereby deprive Memorial of the fruits of its bargain to retain rent.
Plaintiff argues that we should not be concerned with the rights and duties between it and Memorial, leaving a determination of those problems to subsequent litigation between plaintiff and Memorial. We cannot blind ourselves, however, to the obvious consequences to Memorial should plaintiff prevail in the present action.
The order granting defendant's motion for nonsuit, treated as a judgment pursuant to Code of Civil Procedure section 631.8 (see fn. 1, ante), is affirmed.
Tamura, Acting P.J., and Morris, J., concurred.
Appellant's petition for a hearing by the Supreme Court was denied January 13, 1977.
NOTES
[1]  In a trial by the court, which this was, a motion for nonsuit is no longer recognized. The correct motion is a motion for judgment. (See Code Civ. Proc., § 631.8; cf. Code Civ. Proc., § 581c; see also 4 Witkin, Cal. Procedure (2d ed.) pp. 3164-3166.) Accordingly, we treat the order granting defendant's motion for nonsuit as a judgment for defendant pursuant to Code of Civil Procedure section 631.8.
[2]  Subdivision 4 of Code of Civil Procedure section 1161 provides in pertinent part: "Any tenant ... using such [demised] premises for an unlawful purpose, thereby terminates the lease, and the landlord, or his successor in estate, shall upon service of three days' notice to quit ... be entitled to restitution of possession of such demised premises under the provision [sic] of this chapter." (Italics added.)
[3]  Civil Code section 821 provides: "A person to whom any real property is transferred or devised, upon which rent has been reserved, or to whom any such rent is transferred, is entitled to the same remedies for recovery of rent, for nonperformance of any of the terms of the lease, or for any waste or cause of forfeiture, as his grantor or devisor might have had."
[4]  Code of Civil Procedure section 1164 provides in pertinent part: "No person other than the tenant of the premises and subtenant, if there be one, in the actual occupation of the premises when the complaint is filed, need be made parties defendant in the proceeding, nor shall any proceeding abate, nor the plaintiff be nonsuited for the nonjoinder of any person who might have been made party defendant...."
