
768 P.2d 979 (1989)
K. Russell MYERS, Plaintiff and Appellant,
v.
Tawnya MYERS (Luke), Defendant and Respondent.
No. 870379-CA.
Court of Appeals of Utah.
February 2, 1989.
*980 David S. Dolowitz (argued), Julia A. Bryan, Parsons, Behle & Latimer, Salt Lake City, Attys. for plaintiff and appellant.
*981 James O. Haskins, Murray, Atty., for defendant and respondent.
Before BILLINGS, GARFF and GREENWOOD, JJ.

OPINION
GARFF, Judge.
Appellant K. Russell Myers appeals the trial court's order awarding custody of the parties' two children to respondent Tawnya Myers Luke. He alleges that the trial court erred in: (1) permitting respondent to move from Utah to Washington with the children in violation of the parties' stipulation; (2) awarding respondent custody of the children; and (3) not finding respondent in contempt of court for removing the children from Utah in violation of a court order.

FACTS
On May 17, 1985, appellant filed for divorce against respondent. Prior to trial, respondent was awarded temporary custody of the children, a six-year-old girl and a four-year-old boy. In preparation for trial, the parties were ordered to undergo psychological evaluations by Dr. Barbara Liebroder and a custody evaluation by Kim Peterson. These experts concluded that both parties were fit and proper parents to be awarded custody and control of the children, and recommended that custody be awarded to respondent so long as appellant's relationship with the children was not interrupted.
On the date set for trial, the parties stipulated that respondent be awarded custody of the children provided that she remain in or within fifty miles of Salt Lake County, and that she not move from that area with the children without permission of appellant or of the court. Respondent could receive such permission by petitioning the court and establishing, through an evaluation by Peterson, that such a move would be in the best interests of the children. This stipulation was merged into the parties' decree of divorce, which was final on June 9, 1986.
On August 13, 1986, respondent filed a motion for an order permitting her to move from Utah to Washington with the children. The matter was set for hearing in October 1986, but was continued several times to allow Peterson to perform the required follow-up custody evaluation.
On December 13, 1986, after a hearing set for December 12, 1986 was continued, and without leave of the court, respondent moved to Washington with the children.
On December 23, 1986, appellant filed a motion requesting immediate change of custody and determination of contempt against respondent. This motion was heard on January 5, 1987, at which time trial was set for February 20, 1987. The trial court indicated that the issues would be resolved as if the children had not been moved to Washington, and that the removal of the children constituted a substantial change of circumstances sufficient to require further examination by the court. The trial court also ordered Peterson and Liebroder to reevaluate the parties and the children. Upon reevaluation, Peterson recommended that custody of the children be awarded to respondent because it would be less disruptive to the children, while Liebroder recommended that custody be awarded to appellant because he offered the children the best opportunity for long term stability.
After the hearing, the trial court found that there had been a substantial change in circumstances since entry of the divorce decree in that respondent had removed the children from Utah to Washington without the court's permission, and that appellant had undergone therapy to improve his emotional problems. The court also found that both parties were fit and proper persons to be awarded custody of the children, and that it was in the best interest of the children to remain in respondent's custody, provided she undergo psychological therapy, because she could be a full-time caretaker and the children had bonded with her. The trial court did not condition respondent's custody upon her residing in Utah, but ordered liberal visitation for appellant. Travel costs for visitation with appellant *982 were to be apportioned between the parties. Additionally, the court denied appellant's motion to hold respondent in contempt of court, even though it acknowledged that she had violated the court order.
Appellant brought this appeal on August 17, 1987, alleging that the trial court erred in: (1) permitting defendant to move from Utah to Washington with the parties' minor children in violation of the parties' stipulation; (2) awarding defendant custody of the children; and (3) not finding defendant in contempt of court for removing the children from Utah in violation of the court order.
We note, at the outset, that the trial court is given broad discretion in making child custody awards. Shioji v. Shioji, 712 P.2d 197, 201 (Utah 1985). Only where the trial court's findings are "against the clear weight of the evidence, or if the appellate court otherwise reaches a definite and firm conviction that a mistake has been made," will the findings be set aside. State v. Walker, 743 P.2d 191, 193 (Utah 1987).

STIPULATION
Appellant first claims that the trial court erred in permitting respondent to move from Utah to Washington with the children because of the parties' stipulation that she not move from this location with the children without the court's or appellant's permission. Appellant relies upon Despain v. Despain, 627 P.2d 526, 527 (Utah 1981) and Kinsman v. Kinsman, 748 P.2d 210, 212 (Utah Ct.App. 1988) for the proposition that the continuing jurisdiction of the court is limited in setting aside such a stipulation because "[e]quity is not available to reinstate rights and privileges voluntarily contracted away simply because one has come to regret the bargain made." Despain, 627 P.2d at 527 (quoting Land v. Land, 605 P.2d 1248, 1250-51 (Utah 1980)).
First, we note that the parties' stipulation was incorporated into their divorce decree. The trial judge so stated in the decree, and based the language of his findings of fact and conclusions of law on the language of the stipulation. As such, it is an "operative part" of the divorce decree and subject to the continuing jurisdiction of the court. See Stone v. Stone, 647 P.2d 582, 584-85 (Alaska 1982); Howarth v. Howarth, 81 Cal. App.2d 266, 183 P.2d 670, 672-73 (1947).
Despain and Kinsman apply a contract theory to property distribution issues. See Kinsman, 748 P.2d at 212-13. Such a theory is inapplicable to issues which involve the continuing, equitable powers of the court, as here. In Despain, the Utah Supreme Court stated that
[d]efendant has failed to observe the distinction between those cases involving the statutory power of a court in a divorce proceeding to enter orders concerning support and those cases in which the parties in a divorce action have settled their property rights by agreement, the terms of which are incorporated in a decree.
Id. at 527. The court concluded that child support, even if originally set by stipulation, is always open to the court's power of modification upon a proper showing of a substantial change in circumstances.
Similarly, in Balls v. Hackley, 745 P.2d 836 (Utah Ct.App. 1987), this court modified a divorce decree in spite of a contrary stipulation of the parties. We stated, "[t]he parties' stipulation was accepted by the court and incorporated into the decree. The terms of the stipulation thereby fall under the continuing jurisdiction of the court in divorce actions." Id. at 838.
In the present case, the stipulation incorporated into the divorce decree, as in Despain and Balls, deals with an issue normally open to modification under the court's equitable powers, child custody. Utah Code Ann. § 30-3-5(3) (1985). Therefore, it comes under the continuing jurisdiction of the court and may be modified. The trial court is not bound by the parties' stipulation, and may rule otherwise if the circumstances warrant.

CUSTODY
Appellant objects to the trial court's custody award, arguing that it found only that it was in the children's best interest to *983 remain in respondent's custody and did not specifically find that relocating to Washington was in their best interest. He further argues that the trial court abused its discretion in awarding custody by accepting Peterson's recommendations, because Peterson did not take into account all the relevant factors in reaching his conclusion.
Although the trial court is afforded particularly broad discretion in the area of child custody, Hirsch v. Hirsch, 725 P.2d 1320, 1321 (Utah 1986), the Utah Supreme Court, in Hogge v. Hogge, 649 P.2d 51 (Utah 1982), has established a two-step test to determine if a modification of custody is properly granted. Under the first step, the party seeking the modification must demonstrate that: (1) since the time of the previous decree, circumstances upon which the earlier award was based have changed; and (2) these changed circumstances are sufficiently substantial and material to justify reopening the question of custody. Id. at 54; see also Shioji, 712 P.2d at 201; Fullmer v. Fullmer, 761 P.2d 942, 946 (Utah Ct.App. 1988). In the present case, the trial court considered the issue of changed circumstances in the January 5, 1987 hearing on appellant's motion, ruled that respondent's move to Washington in contravention of the court order constituted a substantial change of circumstances sufficient to reopen the question of custody, and set the hearing for determination of custody for February 20, 1987, pending reevaluation of the parties' situations and the custody arrangements.
Under the second Hogge step, if a substantial change in circumstances is found, the trial court must then determine de novo which custody arrangement is in the child's best interest. Hogge, 649 P.2d at 54; see also Shioji, 712 P.2d at 201; Fullmer, 761 P.2d at 946. It is well-settled that to properly review child custody determinations, the record on review must "contain written findings of fact and conclusions of law by the trial judge which specifically set forth the reasons, based on those numerous factors which must be weighed in determining `the best interests of the child,' and which support the custody decision." Ebbert v. Ebbert, 744 P.2d 1019, 1021 (Utah Ct.App. 1987) (quoting Smith v. Smith, 726 P.2d 423, 425 (Utah 1986)); see also Painter v. Painter, 752 P.2d 907, 909 (Utah Ct.App. 1988). The trial court must also indicate that there is a "logical and legal basis" for its ultimate conclusions, setting forth the basic facts which show why that conclusion is justified. Smith, 726 P.2d at 426.
Because a custody determination may frequently involve a choice between good and better, Shioji, 712 P.2d at 201-02, trial courts should consider various relevant factors in determining which custodial arrangement is in the child's best interest. Even though no one set of factors governs a custody determination in every case, "the trial court's findings should articulate those factors pertinent to the child's best interests which the court considered in making its determination, such as the needs of the child, the ability of each parent to meet those needs," Painter, 752 P.2d at 909; see also Smith, 726 P.2d at 425-26, "the parenting ability of the custodial parent and the functioning of the established custodial relationship." Chandler v. Matthews, 734 P.2d 907, 908 (Utah 1987). Other function-related factors which are relevant in choosing between custodial situations include the identity of the primary caretaker during the marriage, the identity of the parent with greater flexibility to provide personal care for the child, the stability of the environment provided by each parent, and the identity of the parent with whom the child has spent most of his or her time pending custody determination. Pusey v. Pusey, 728 P.2d 117, 120 (Utah 1986); see also Hogge, 649 P.2d at 55. However, the trial court should be careful not to reward the primary care-giver, if he or she gained that status wrongfully, by giving the wrongdoer a consequential advantage in evaluating the custody question. Davis v. Davis, 749 P.2d 647, 648-49 (Utah 1988).
The trial court found, among other things, that: (1) respondent was the primary caretaker under the original decree of divorce; (2) she had remarried and filed *984 a motion for permission to leave the State of Utah based upon her husband's employment in Washington; (3) even though her stability had degenerated since the entry of the divorce, a large part of it was caused by post-divorce problems; (4) Peterson had recommended that it was in the children's best interest for respondent to retain custody because of (a) appellant's prior conduct, (b) respondent's ability to be a full-time caretaker, (c) respondent's bond with the children, and (d) the unnecessary trauma to the children involved in changing the custodial parent; and (5) Nathan, the four-year-old boy, was hyperactive and in need of therapy. The court concluded that, although "both parents were fit and proper persons to be awarded custody of said minor children," it was in the children's best interest that they remain in respondent's custody. It also conditioned this order upon respondent beginning and continuing psychological therapy until no longer required, upon the parties providing Nathan with psychological therapy and keeping the court informed of his progress, and upon plaintiff's reasonable visitation with the children. It is clear from these findings that the trial court considered the needs of the children and the parties' ability to provide for these needs, especially with respect to Nathan. It considered the identity of the primary caretaker with whom the children had bonded, the needs of the children for stability in their environment, and the identity of the parent who could provide personal care as factors in the custody determination. Although the court did not specifically state that it was in the children's best interest to move to Washington, it is reasonable to infer that the court's determination of the children's best interests included consideration of this move. Notably, the judge did not give special consideration to the relationship between the children and respondent as caretaker during the pendency of the custody determination because he had told appellant that he would not give respondent an advantage as a result of having moved the children to Washington prior to the trial. We thus find that the trial court presented adequate written findings of fact to set forth its reasons for the custody determination.
The trial court is best suited to assess the factors upon which it based its determination, given its proximity to the parties and circumstances, and its opportunity to personally observe and evaluate the witnesses. Alexander v. Alexander, 737 P.2d 221, 223 (Utah 1987); see also Kramer v. Kramer, 738 P.2d 624, 628 (Utah 1987). "The issue on appeal is not whether the trial court's findings accord with our own view of the evidence, but whether, viewing the evidence and the reasonable inferences therefrom in the light most favorable to the findings, the findings are supported by the evidence." Shioji, 712 P.2d at 201. "Only where the trial court action is so flagrantly unjust as to constitute an abuse of discretion should the appellate forum interpose its own judgment." Lembach v. Cox, 639 P.2d 197, 201 (Utah 1981) (quoting Jorgensen v. Jorgensen, 599 P.2d 510, 511-12 (Utah 1979)) rev'd on other grounds. Upon a thorough review of the record, we find that there was substantial evidence presented to support each of the trial court's factual findings.
We note that the trial court is free to accept or reject an expert's testimony, and may accord it whatever weight it deems appropriate in the light of all the other evidence in the case. See State v. Shickles, 760 P.2d 291, 302 (Utah 1988); Pusey, 728 P.2d at 120. Because of this discretion, the trial court was entitled to accord less weight to Dr. Liebroder's recommendation and rely on other evidence, including Peterson's evaluation and recommendation. We affirm the trial court's custody determination.

CONTEMPT
Although "[t]he duty to hold in contempt in a civil matter in order to afford relief to another party does not lie within the discretion of the trial court," Butler v. Butler, 23 Utah 2d 259, 461 P.2d 727, 729 (1969), "a person who puts forth every reasonable effort to comply with a court order and still is unable to do so, is not guilty of contempt on account of such failure." Limb v. *985 Limb, 113 Utah 385, 195 P.2d 263, 265 (1948).
The trial court's findings, which were based upon substantial evidence, indicated that respondent filed a motion for permission to leave the State of Utah because of her husband's employment, but removed herself and the children to Washington without such permission when the hearing on the motion was continued. The record indicates that she put forth every reasonable effort to comply with the court order. By the time respondent left Utah in December 1986, the hearing on the motion had been continued three times, Dr. Liebroder and Peterson had not completed their evaluations, respondent was unemployed, had to move from her apartment and move in with her parents, was transporting her daughter 120 miles per day to and from school, had no income because appellant was delinquent in his child support payments, was unable to be with her husband who was already working in Washington, was in her third trimester of pregnancy, and would soon be unable to travel. Further, the record indicates that respondent properly filed her motion for permission to leave the state and cooperated, at great personal effort and expense, with the experts in obtaining the evaluations. Therefore, we find that the trial court did not abuse its discretion in denying appellant's order to find respondent in contempt of court.
AFFIRMED.
BILLINGS and GREENWOOD, JJ., concur.
