OPINION
FABE, Justice.I. INTRODUCTION
This appeal involves a dispute between B.J. and J.D. over the custody of V.J., B.J.’s daughter. The court awarded primary physical custody to J.D., who is not the child’s biological father, and B.J. appeals. She argues that the superior court lacked jurisdiction over the case and that it applied the wrong standard in awarding custody. Because the superior court properly assumed jurisdiction under the Uniform Child Custody Jurisdiction Act (UCCJA) and made factual findings consistent with the “welfare of the child” test that is applicable to a custody suit involving a non-biological parent, we affirm. B.J. also contends that the trial court erred in denying her motion for attorney’s fees. However, because there is no evidence that J.D. acted in bad faith under AS 25.20.115, we conclude that the superior court’s denial of B.J.’s motion for attorney’s fees was not an abuse of discretion.
II. FACTS AND PROCEEDINGS
B.J. and J.D. met in 1986. They had an intimate relationship, sometimes living together, until 1993. V.J. was. born in Fairbanks in June 1989. At the time of V.J.’s birth, B.J. and J.D. were not living together, although J.D. would often spend the night at B.J.’s apartment. J.D. testified at trial that he believed, and B.J. told him repeatedly, that he was V.J.’s biological father. Both B.J. and J.D. helped care for V.J., and J.D. provided financial support to B.J. and V.J.
J.D. and B.J. ended their relationship in 1993.1 J.D. apparently sent V.J. to be cared for in Anchorage, but V.J. was returned to B.J.’s custody by court order. J.D. did not see the child for several months. He initiated a custody action in May 1993, but a court-ordered paternity test established that he was not V.J.’s father, and the trial court dismissed the custody action.
In November 1993 B.J. took V.J. to Hawaii.2 B.J. and V.J. apparently lived in at least five locations during their approximately two years in Hawaii. B.J. lived with roommates and sometimes families with whom B.J. would trade child care responsibilities. J.D. maintained contact with V.J. through the phone and the mail.
In February 1995 B.J. sent V.J. to J.D. for an indefinite stay. V.J. lived in Fairbanks with J.D. for five months while B.J. remained in Hawaii.
In July 1995 B.J. returned to Fairbanks and attempted to regain custody of V.J. J.D. filed an action seeking legal and primary physical custody of V.J. After hearings on interim custody, Superior Court Judge Jay Hodges ordered a shared alternating week custody schedule. After another series of hearings on interim custody, Judge Hodges modified this order due to concerns raised by *115a counselor and a doctor, both of whom had examined Y. J.
■Dr. Marvin Bergeson, in his report and testimony, concluded that V.J. showed physical signs “highly suspicious for sexual abuse.” These physical signs included “a very large hymenal opening, with the hymen being thickened, narrow, irregular.” He testified that such findings were consistent with “chronic penetration” in the past, although not in the period immediately preceding the examination.
The counselor, Aviva Stinson, testified that V.J. insisted she did not want to go to her mother and that V.J. acted strangely when the subject of her mother came up.3
The superior court restricted B.J. to supervised visitation with V.J. pending trial. Supervisors and counselors who observed the interaction between B.J. and V.J. during these visits later testified that the mother-daughter relationship appeared awkward, unnatural, and unaffectionate.
A three-day trial took place in June 1996. The superior court found that it had jurisdiction over the action. After hearing the evidence, the court awarded shared legal custody to the parties but concluded that V.J.’s welfare and best interest “dictate[d] that the father [J.D.] should have physical custody.” The court found that “based on the mother’s prior conduct ... [V. J.]’s welfare would be in jeopardy if the mother has custody.” The court expressed concern about B.J.’s “desire to meet the needs of the child relative to any type of loving relationship,” and concluded that B.J. “has demonstrated that she does not have the capacity to meet” V.J.’s “physical, emotional, mental, religious and social needs.” The court, however, expanded B.J.’s visitation rights to include unsupervised overnight visits. After two further hearings to clarify visitation, the court signed a custody decree on September 19,1996. The superior court denied B.J.’s motion for attorney’s fees. B.J. appeals.
III. DISCUSSION
A. Did the Superior Court Have Jurisdiction under the Uniform Child Custody Jurisdiction Act?
B.J. first challenges the superior court’s assumption of jurisdiction over this dispute. J.D. argues that B.J. waived this argument by failing to raise the issue of jurisdiction until her trial brief, nearly a year after J.D. commenced the superior court proceedings.
Subject matter jurisdiction is generally a matter of law that we review de novo. See Hydaburg Cooperative Ass’n v. Hydaburg Fisheries, 925 P.2d 246, 248 (Alaska 1996). Because “subject matter jurisdiction issues may be raised at any time during litigation” and “jurisdiction otherwise lacking cannot be conferred by estoppel,” the issue of subject matter jurisdiction was properly before the superior court. O’Link v. O’Link, 632 P.2d 225, 226-27 n. 2 (Alaska 1981).
Jurisdiction in custody matters is governed by the Uniform Child Custody Jurisdiction Act. See AS 25.30.020(a).4 A court must determine whether jurisdiction under the UCCJA “exists or does not exist at the time when the petition is filed with the court.” Rexford v. Rexford, 631 P.2d 475, 478 (Alaska 1980).
*116B.J. contends that none of the conditions for exercising jurisdiction under the UCCJA exists. She asserts that Alaska was not V.J.’s “home state,” that V.J. was not a child in need of aid, and that Hawaii had jurisdiction. While J.D. concedes that Alaska was not V.J.’s “home state” under AS 25.30.020(a)(1)(A) at the time he filed the action,5 he maintains that the superior court properly asserted jurisdiction under AS 25.30.020(a)(3). We agree.
The superior court determined that it had jurisdiction under AS 25.30.020(a)(3), because it “appear[ed] that no other state would have jurisdiction under prerequisites substantially in accordance with (1) or (2) of th[e] subsection.” AS 25.30.020(a)(3)(A). Neither Alaska nor Hawaii was V.J.’s home state at the time of filing. When J.D. filed the action, B.J. did not live in Hawaii and did not intend to return to Hawaii. Thus, because no “parent or person acting as parent” continued to live in Hawaii, that state, could not have exercised jurisdiction.
Additionally, resolving this custody dispute in Alaska, rather than dismissing it when no other state had jurisdiction, appears to have been “in the best interest of the child.”6 AS 25.30.020(a)(3)(B). The purposes of the UC-CJA include
assuring] that litigation concerning the custody of a child takes place ordinarily in the state with which the child and the child’s family have the closest connection and where significant evidence concerning the child’s care, protection, training, and personal relationships is most readily available.
AS 25.30.010(3).7 The UCCJA is also designed to “discourage continuing controversies over child custody in the interest of greater stability of home environment and of secure family relationships for the child.” AS 25.30.010(4). Both of these policy considerations weigh in favor of the superior court’s assertion of jurisdiction in this case.
We affirm the superior court’s assumption of jurisdiction under AS 25.30.020(3). No other state would have had jurisdiction of the case under the UCCJA at the time the action was filed, and it was in V.J.’s best interest for Alaska to exercise jurisdiction over this matter.
B. Did the Superior Court Abuse Its Discretion in Awarding Custody of V.J. to J.D. ?
1. Standard of review
We will only reverse the superior court’s.determination of child custody issues if we are satisfied that
the record shows an abuse of discretion or if the controlling factual findings are clearly erroneous. Abuse of discretion is established if the trial court considered improper factors or failed to consider statutorily mandated factors, or improperly weighted certain factors in making its determination.
McQuade v. McQuade, 901 P.2d 421, 424 n. 9 (Alaska 1995) (citations and quotations omitted).
*1172. “Welfare of the child” is the correct test to apply where custody could be awarded to a person other than the biological parent.
B.J. argues that the superior court failed to apply the “welfare of the child” test articulated in Turner v. Pannick, 540 P.2d 1051 (Alaska 1975) in awarding custody of V.J. to J.D., who is neither a biological parent nor a stepparent.
In Turner v. Pannick, we held that an award of custody to a natural parent is “preferable and only to be refused where clearly detrimental to the child.” Id. at 1055. We identified only three circumstances under which a superior court may award custody to a person other than the biological parent: (1) when the biological parent is unfit; (2) when the biological parent has abandoned the child; and (3) when the welfare of the child requires that a non-parent receive custody. Id. We have reaffirmed these principles in Britt v. Britt, 567 P.2d 308, 310 (Alaska 1977), Buness v. Gillen, 781 P.2d 985, 988-89 (Alaska 1989), and Rooney v. Rooney, 914 P.2d 212, 216 n. 8 (Alaska 1996).
J.D. argues that the preference for natural parents established by Turner does not apply to this case and relies on Carter v. Brodrick, 644 P.2d 850 (Alaska 1982) to support this contention. Carter, however, did not hold that a biological parent is not preferred over a third party who stands in loco parentis to the child in the determination of custody. Rather, it dealt only with visitation, not custody, and involved a stepfather (the natural mother’s former husband), not an unrelated third party. Id. at 855. Indeed, in Carter, we expressly reaffirmed Turner, stating that a court “would have jurisdiction to award custody of a stepchild to the stepparent if the court found that custody with the natural parent would be clearly detrimental to the child.” Id. We therefore apply the “welfare of the child” test in this case.
B.J. argues that the superior court incorrectly applied the “welfare of the child” test by failing to find that awarding custody to B.J. would be clearly detrimental to V.J. We disagree. A careful review of the superior court’s oral findings and written custody decree reveals that the superior court made adequate findings consistent with the standard we prescribed in Turner.
The superior court based its oral finding that “[V.J.j’s welfare would be in jeopardy if the mother has custody,” upon the evidence adduced at trial. The superior court relied on testimony regarding B.J.’s inability to provide a stable home environment or meet her daughter’s needs.
The trial court heard testimony that B.J. lived a transient lifestyle while in Hawaii between 1993 and 1995. During that time she and her daughter resided at five different addresses, usually shared with other families or individuals who would take responsibility for caring for V.J. B.J. admitted at trial that she was unable to provide a stable life for V.J. during the time they were in Hawaii.8 These facts led the court to conclude that “Hawaii was really not an acceptable place under the circumstances for [V-J-],” that “she has lived in an unstable, chaotic situation,” and that “based on the mother’s prior conduct ... [V- J.]’s welfare would be in jeopardy if the mother has custody.”
Furthermore, the testimony of medical experts and counselors suggested that V.J. had been sexually abused while in Hawaii under her mother’s care. Although the superior court found that B.J. was neither aware of nor directly involved in the sexual abuse, the court was clearly concerned about the “child’s adverse reaction,” and found that “her welfare is best served by physical custody in [J.D.].”
The court also addressed B.J.’s inability to provide for the physical, emotional, mental, religious and social needs of V.J. The court’s finding that B.J. “has demonstrated that she does not have the capacity to meet those needs” is consistent with the evidence in the record. Testimony from persons who supervised B.J.’s visitations in Fairbanks, a *118custody investigator, and counselors observing interactions between B.J. and V.J., all indicated that the mother-daughter relationship was unaffectionate and awkward. The testimony further suggested that B.J. at times acted inappropriately towards her child, on one occasion slapping V.J.’s forehead and pulling her ears, while on another striking V.J. with a closed fist while tussling with a visitation supervisor. According to the testimony at trial, B.J. also admitted to the custody investigator that she had difficulty disciplining V.J. and wanted and needed help earing for her. The superior court also considered testimony that V.J. was reluctant to visit B.J. unaccompanied or converse with her on the phone. In its oral and written findings, the court noted V.J.’s “concerns regarding her mother,” and concluded that it would “not be in [V.J.]’s welfare or interests to return physical custody to [B.J.]
The professionals who testified at trial also challenged B.J.’s judgment as a parent9 and expressed concern that if she were awarded custody, V.J.’s “future will be gone.” The court echoed this sentiment by questioning B.J.’s “desire to meet the needs of the child relative to any type of loving relationship.” Troubled by B.J.’s plans to go to South Carolina 10 and her transient lifestyle in general, the court commented, “[t]here is some indication that [B.J.] ... is not aware of the necessity of the type of relationship that should exist between [J.D.] and [V.J.].”
The superior court appropriately applied the Turner standard and concluded that “it would not be in [V.J.’s] welfare ... to return physical custody to [B.J.],” and that “[V.J.]’s welfare would be in jeopardy if the mother had custody.” In light of these findings, which are substantiated by the record, we conclude that the trial court did not abuse its discretion “by considering] improper factors or failing] to consider statutorily-mandated factors, or improperly weighting] certain factors in making its determination.” McQuade, 901 P.2d at 424 n. 9 (citations omitted). Therefore, we affirm the superior court’s award of custody to J.D.
C. Did the Superior Court Err in Denying B.J.’s Motion for Attorney’s Fees?
B.J. argues that she was entitled to attorney’s fees and maintains that the superi- or court should have considered the “relative economic situations and earning powers of the parties when deciding whether to grant or deny her motion.” Lone Wolf v. Lone Wolf, 741 P.2d 1187, 1192 (Alaska 1987) (approving exception to Alaska Civil Rule 82 in cases of divorce). J.D. contends that this limited exception to the rule of prevailing party attorney’s fees is inapplicable. He contends that AS 25.20.115 governs the award of attorney’s fees resulting from an action to modify, enforce or vacate a child custody award.
The decision of which statute or rule applies to an award of fees presents a question of law. The standard of review on questions of law is de novo or independent review. See Langdon v. Champion, 752 P.2d 999, 1001 (Alaska 1988).
The rule upon which B.J. relies is not applicable because the instant action did not involve the dissolution of a marriage. We have previously held that the divorce exception to Civil Rule 82 “is based on a broad reading of AS 25.24.140(a)(1) [pertaining to an interim award of attorney’s fees in divorce eases] ..., and on the reality that there is usually no prevailing party in a divorce case.” L.L.M. v. P.M., 754 P.2d 262, 264 (Alaska 1988). Neither of these reasons applies here because this is not a divorce case and J.D. was clearly the prevailing party.
In Bergstrom v. Lindback, 779 P.2d 1235, 1238 (Alaska 1989), we applied the “divorce exception” to a custody dispute between an unmarried couple both of whom were biologi*119cal parents of the child. The present case is distinguishable in many respects. It concerns the rights of a biological parent in relation to those of a non-biological parent. Although the parties in Bergstrom had never been married, they had been living together as husband and wife for fourteen years, and the custody dispute litigated there was closely analogous to custody disputes in divorce cases. Here, by contrast, J.D. filed this action more than three years after the parties had voluntarily ended their relationship and after the trial court had dismissed a lawsuit by J.D. seeking custody as a biological parent. The present case does not bear the same close resemblance to an initial custody proceeding in a divorce action as did Berg-strom.
J.D. argues that the circumstances of this case are more akin to the modification of a custody award than to a divorce action. Alaska Statute 25.20.115 provides
[i]n an action to modify, vacate, or enforce that part of an order providing for custody of a child or visitation with a child, the court may, upon request of a party, award attorney fees and costs of the action. In awarding fees and costs under this section, the court shall consider the relative resources of the parties and whether the parties have acted in good faith.
Although by its terms the statute applies only to actions to “modify, vacate and enforce” child custody and visitation awards, we conclude that it is applicable to the present case. In J.D.’s initial action to gain custody of V.J., filed when he still believed himself to be her natural father, Superior Court Judge Jay Hodges entered a temporary order regarding visitation. J.D. was granted visitation rights, but B.J. was given physical custody of V.J. and the authority to take her to Hawaii on the condition that she return for the start of trial later the following year. When the paternity test established that J.D. was not the biological father, the court dismissed J.D.’s complaint and custody of V.J. remained with B.J. By filing his 1995 complaint and expedited motion for temporary orders, J.D. attempted to modify the substance of the court’s earlier custody order and the status quo. Therefore, AS 25.20.115 governs J.D.’s efforts to regain custody of V.J.
With respect to modification of custody and visitation orders, we review the denial of a motion for attorney’s fees for abuse of discretion. See Kessler v. Kessler, 827 P.2d 1119, 1120 n. 4 (Alaska 1992). In addressing attorney’s fees under AS 25.20.115 the court must consider the parties’ relative economic situations, as well as whether they have acted in good faith. “The parties’ relative financial resources do not necessarily take primacy over the presence or absence of good faith.” S.L. v. J.H., 883 P.2d 984, 985-86 (Alaska 1994). B.J. failed to allege at anytime during the proceedings below or in her points on appeal that J.D. acted in a vexatious manner or in bad faith. Thus, the superior court did not abuse its discretion by denying B.J.’s motion for attorney’s fees.
IV. CONCLUSION
We AFFIRM the trial court’s assumption of jurisdiction, its award of primary physical custody to J.D., and its denial of B.J.’s motion for attorney’s fees.
. According to J.D., he continued to support both B.J. and V.J. financially from 1993 onward, paying medical and dental bills, covering B.J.'s rent when she was unable to pay it, and reconnecting B.J.'s phone when she failed to pay her bills so that he could stay in touch with V.J.
. B.J.’s brief states, without record support, that she moved to Hawaii in "early 1993.” However, B.J. testified at trial that she moved at "the end of November” in 1993.
. Stinson, in later testimony, discussed her observations of V.J. and concluded that there was no doubt in her mind that she had heen sexually abused.
. Alaska Statute 25.30.020(a) provides:
The superior court has jurisdiction to make a child custody determination by initial or modification decree if the conditions set out in any of the following paragraphs are met:
(1)this state (A) is the home state of the child at the time of commencement of the proceeding, or (B) had been the child’s home state within six months before commencement of the proceeding and the child is absent from this state because of removal or retention by a person claiming custody or for other reasons, and a parent or person acting as parent continues to live in this state; or
(2) the child is physically present in this state and is a child in need of aid as defined in AS 47.10.990; or
(3) it (A) appears that no other state would have jurisdiction under prerequisites substantially in accordance with (1) or (2) of this subsection, or another state has declined to exercise jurisdiction on the ground that this state is the more appropriate forum to determine the custody of the child, and (B) is in the best interest of the child that this court assume jurisdiction.
.The UCCJA defines the term "home state” as "the state in which the child, immediately preceding the time involved, lived with the child's parents, a parent, or a person acting as parent, for at least six consecutive months.” AS 25.30.900(5). The phrase "person acting as parent” is defined as "a person, other than a parent, who has physical custody of a child and who has either been awarded custody by a court or claims a right to custody.” AS 25.30.900(9). Finally, the act defines "physical custody” as "actual possession and control of a child.” AS 25.30.900(8). Because J.D. had "actual possession and control” of V.J. and "claim[ed] a right to custody” at the time he filed the action, he was a "person acting as parent” under the UC-CJA. However, according to the testimony at trial, V.J. arrived in Fairbanks from Hawaii sometime in February 1995. J.D. filed his action on July 24, 1995, after V.J. had been in Fairbanks for at most five months and about three weeks.
. We note for the purpose of clarity that the "best interest of the child” is being considered solely with respect to jurisdiction and not as the basis for awarding custody in matters involving a non-biological parent.
. The superior court found that the "primary witnesses involved in this case are here in Alaska in the Fairbanks area” and concluded that Hawaii would be an inappropriate forum "[u]nder the facts and circumstances of this case, particularly where [B.J.] has indicated she doesn’t even want to go back to Hawaii.”
. B.J. continued to have difficulty securing housing when she returned to Fairbanks. By the start of trial, she had lived in at least seven different places. Additionally, J.D. testified that he usually had to cover B.J.’s expenses when she received eviction notices or was unable to pay rent.
. Other witnesses testified about B.J.’s lack of parenting skills, alluding to a number of instances in which young children, including V.J., were permitted to stay in the room while adults were viewing pornographic films.
. B.J. intended to seek support in raising V.J. from her family in South Carolina. The custody investigator testified that he was concerned about that plan because B.J. had been physically abused by her adoptive parents, and because her contact and relations with her 19 siblings and adoptive parents were not current.