Evelyn Holmes Spriggs, trustee and income beneficiary of the B. E. (Earl) Holmes Testamentary Trust, appeals the district court’s order requiring her to return to the trust all the money that she had received from the sale of stock which had been a part of the trust corpus. The district court’s order arose from an action that was brought by Tanua Smith, one of the remaindermen and Evelyn’s daughter, to set aside the disbursement that Evelyn had made to herself.
Earl Holmes executed his last will and testament on January 23, 1965. Holmes died on July 4,1965. Holmes’ will passed a life estate in his 3,480-acre ranch first to his nephew, Elmer Holmes, then upon Elmer’s death to Elmer’s daughter, Evelyn Wolkins (now Spriggs), and upon Evelyn’s death to Evelyn’s issue per stirpes in fee simple. All intangible personal property was transferred to Chester B. Fullerton, president of the First National Bank of Medicine Lodge, Kansas, (Bank) to be held in trust with the income therefrom to go to Elmer for life, then to Evelyn for life, and upon *388Evelyn’s death, the principal of the trust to be divided among Evelyn’s issue per stirpes.
As set out in Holmes’ will, the trust provided that in the event of the original trustee’s death, the then-president or managing officer of the Bank and the then-income beneficiary of the trust would serve as successor trustees. Elmer Holmes died in 1977, and the original trustee died in 1987. Thereafter, the then-president of the Bank, the successor co-trustee, declined to serve, and Evelyn became the sole trustee in 1988.
The 1965 inventory and appraisement included 29.4 shares of stock in the Bank and 135.55 shares of stock in United Accumulative Fund (Fund). At that time, the Bank stock had a value of $8,820. In 1978, the Fund stock was sold and all proceeds from the sale went into the trust. In 1981, the Bank stock was exchanged for 147 shares of stock in First Medicine Lodge Bancshares, Inc. (Bancshares). In 1992, the Bank again changed hands and the new owners wanted to redeem all of the stock, offering $285,297.45 for the trust’s 147 shares of Bancshares stock. Upon the advice of her attorney and the approval of the district court, Evelyn sold the trust’s 147 shares of stock.
Evelyn then sought advice from her attorney on how to handle the proceeds from the sale of the stock. Evelyn’s attorney interpreted the trust as giving the trustee broad discretion in allocation of receipts and advised Evelyn to return the original basis of the stock, $8,820, to the trust corpus, and to distribute the remaining $276,477.45, minus attorney fees, to herself as the income beneficiary. Evelyn obtained an ex parte order from the district court which affirmed this distribution.
Upon discovering these events, Smith brought a motion to set aside the district court’s ex parte order for lack of notice. After a hearing on this motion, a magistrate judge ordered Evelyn to return the sum of $275,727.45 to the trust.
On August 25, 1995, the district court issued a memorandum decision upholding the magistrate’s order. The district court found that the trustee’s allocation of the Bank stock receipts of $8,820 to principal and the balance to income was an abuse of discretion. The district court ruled that the trustee had a fiduciary duty when *389allocating receipts as expressed by K.S.A. 58-903(a)(3). The district court found further that when stock increases in value while being held in trust, although the increase reflects undistributed corporate earnings, the increase becomes part of the corpus. The trust provided for invasion of the corpus solely for unusual medical expenses. The express authority to invade the corpus for a specific purpose combined with the absence of express authority as a power of appointment gave further support to the district court’s conclusion. Finally, the district court found that the creation of successive life interests was compatible with an intent to pass wealth as far down the family tree as possible with a minimum of estate taxes and that broad powers of allocation would be contrary to this intent.
Evelyn argues that the will granted the trustee broad powers of discretion to dispose of and allocate property between income and corpus. Smith argues that such an interpretation would contravene Holmes’ intent and would be contrary to Evelyn’s fiduciaiy duty to the remaindermen.
“The construction of a written instrument is a question of law, and the instrument may be construed and its legal effect determined by an appellate court. [Citation omitted.] Where a court, either trial or appellate, is called upon to determine the force and effect to be given terms of a will, the court’s first duty is to survey the instrument in its entirety and ascertain whether its language is so indefinite and uncertain as to require employment or rules of judicial construction to determine its force and effect. [Citations omitted.] Where the language of a will is clear, definite, and unambiguous, the court should not consider rules of judicial construction to determine the intent of the testator. [Citation omitted.] In the interpretation of wills, the primary function of the court is to ascertain the testator’s intent from the four comers of the will and to carry out that intent if possible and not contrary to law or public policy. [Citation omitted.]” In re Estate of Cline, 258 Kan. 196, 199, 898 P.2d 643 (1995).
The district court found that the will was not ambiguous and, therefore, the intent of the testator should be determined from the four comers of the will. The district court also found that the will neither provided broad general powers of appointment nor granted the trustee power to invade the corpus for anything except unusual medical expenses.
*390Article IX of Holmes’ will sets forth the trustee powers as follows:
“B. [The Trustees] shall determine the allocation of receipts between corpus and income, and shall not be required to make any provision on account of increase or decrease in value, or on account of any depreciation or amortization of any of the property of the estate or trust. [The Trustees] shall determine the manner in which expenses incurred in the administration of the Estate or Trust shall be apportioned between corpus and income.
“C. In the event either Elmer Holmes or Evelyn Wolkins needs [assistance] during the existence of the Trust to meet unusual medical expenses for themselves or members of their respective immediate families, then the Trustees shall have authority to invade the corpus to the extent they deem necessary or advisable to furnish such assistance.
“D. [The Trustees] may make distributions in the administration of the estate or trust wholly or partly in cash or kind.
“E. It is my suggestion that the principal of the Trust be invested in good, interest bearing securities or savings accounts, but the [Trustees] shall be entitled to use their own discretion in the matter of investment or reinvestment of the Trust property.”
The district court held that Article IX.B. of the will merely relieved the trustee of any responsibility for fluctuations in the value of the trust corpus.
All the parties agree that the will is unambiguous. Evelyn maintains that the will demonstrates that Holmes intended to pass his estate with a minimum of estate taxes without rendering the will invalid by reason of the rule against perpetuities, to keep the ranch intact, and to properly care for Elmer and Evelyn. Smith supports the trial court’s conclusion that broad allocation powers contravene a testator’s intent to pass property as far down the family line as possible and, therefore, a trustee has a fiduciary duty to maintain the corpus for the remaindermen.
It is a longstanding rule that the testator’s intent controls. In re Estate of Egy, 205 Kan. 303, Syl. ¶ 1, 469 P.2d 319 (1970). Under Article IX.C. of the will, the trustee had the power to invade the corpus only for unusual medical expenses.
There is no language in the trust which grants additional powers other than those authorized by the Kansas Uniform Principal and Income Act, K.S.A. 58-901 et seq., which was last amended in 1965. The will does not grant the trustee the power to take part of the *391corpus and designate it as income. Such action on the part of the trustee is an invasion of the corpus for purposes other than allowed by the trust document.
K.S.A. 58-904 addresses the right to and the apportionment of income. K.S.A. 58-903 designates what is to be considered as income and what is to be classified as principal. K.S.A. 58-903(b) provides in part:
“Principal is the property which has been set aside by the owner or the person legally empowered so that it is held in trust eventually to be delivered to a remainderman while the return or use of the principal is in the meantime taken or received by or held for accumulation for an income beneficiary. Principal includes (1) consideration received by the trustee on the sale or other transfer of principal or on repayment of a loan or as a refund or replacement or change in the form of principal;
(4) stock dividends, receipts on liquidation of a corporation, and other corporate distributions as provided in K.S.A. 58-905;
(8) any profit resulting from any change in the form of principal except as provided in K.S.A. 58-911.”
The sale of the Bancshares stock was a total liquidation of a trust asset, which produced a much greater amount than the original purchase price. Therefore, the sale falls squarely within K.S.A. 58-903(b)(8).
The question of a trustee’s duty and the allocation of a gain or loss from the sale of capital assets was addressed in Jennings v. Speaker, Executrix, 1 Kan. App. 2d 610, 571 P.2d 358 (1977).
Jennings, as in this case, involved a trustee who was also a remainderman, although here the trustee is the income beneficiary. In Jennings, 1 Kan. App. 2d 610, Syl. ¶¶ 2, 6, the court held:
“Where a trustee is also the remainderman of a trust he has a conflict of interest with the income beneficiaiy requiring scrupulous fairness and impartiality in allocating receipts between principal and income.”
“Gains and losses from the sale of capital assets owned by a trust are allocable to the principal account.”
In Gaskill v. United States, 238 Kan. 238, 708 P.2d 552 (1985), the Kansas Supreme Court answered a certified question from the *392Tenth Circuit Court of Appeals concerning the powers and rights of a life tenant. The question posed to our Supreme Court was:
“Does a life tenant of property given to her in a will which authorizes her to dispose of the property as provided in Articles III [of the Gaskill will] have a right under Kansas law to consume the corpus where Article IV of the [Gaskill] will gives the remainder ‘subject to the life estate’?” 238 Kan. at 238.
The Kansas Supreme Court answered as follows:
“Where there are no clear provisions governing disposition of the proceeds of a sale by a life tenant in the will, the proceeds of a sale or disposition by a life tenant take die place of the property sold, so that title thereto is in the remaindermen, subject to such rights of possession, user, investment, reinvestment, expenditure, or consumption as may have been given the life tenant under the will. Annot., 47 A.L.R.3d 1078,1082.” 238 Kan. at 241.
We hold that gains or losses from the sale of all or part of the trust corpus are allocable to the corpus and do not become income unless there is specific language in the trust document granting the trustee broad power to invade the corpus for that purpose. The proceeds from the sale of the Bancshares stock should be returned to the trust corpus as provided for in K.S.A. 58-903(b).
Affirmed.