The petitioners, P.B. and S.B., appeal an order of the Circuit Court {Ryan, J.) approving the Judicial Referee’s {Rein, M.) recommendation that their petition for visitation with their grandson C.W. be denied. The respondents, T.W. and S.W., cross-appeal an order of the circuit court denying their earlier motion to dismiss the petition. On appeal, the petitioners argue that the trial court erred in balancing the factors regarding the best interests of the child. In their cross-appeal, the respondents argue that the trial court erred in interpreting RSA 461-A:13 (Supp. 2014) to permit the petitioners to maintain their petition for grandparent visitation after the respondents adopted C.W. We affirm.
The trial court found, or the record reflects, the following facts. C.W. was born to M.M. and K.B. on March 31,2011. His birth parents died tragically on January 11, 2012. Since then, the respondents, M.M.’s sister and brother-in-law, have cared for C.W., initially as guardians and, since June 24, 2013, as adoptive parents. The petitioners, K.B.’s mother and father, had “consistent — but not extensive — contact” with C.W. before his birth parents died and approximately 16 visits between January 17, 2012, and September 1, 2012, after C.W. began residing with the respondents.
On February 15, 2012, the petitioners filed a petition for grandparent visitation in the trial court. After a hearing, the trial court entered a temporary visitation order that mandated unsupervised visitation from 9:00 a.m. to 2:00 p.m. on the first and third Saturdays of every month. After the respondents adopted C.W., they moved to dismiss the petition for grandparent visitation and vacate the temporary order. The trial court denied this request.
On February 12,2014, the trial court issued a final ruling on the petition for grandparent visitation. After considering the criteria set forth in RSA 461-A:13, the trial court concluded that the respondents’ testimony and conduct before the temporary visitation order demonstrated their intention to support a relationship between C.W. and the petitioners, that the *629respondents “have [C.W.’s] best interests uppermost in their minds and... will utilize appropriate judgment in determining whether and how best to integrate [the petitioners] into [C.W.’s] life[,]” and that “[C.W.’s] best interests will be served by a full integration into his adopted family... from which he can explore his relationship with the [petitioners’] family, under the supervision and judgment of his parents.” Accordingly, the trial court denied the petition for grandparent visitation. This appeal followed.
We first address the cross-appeal. The respondents assert that the trial court misconstrued RSA 461-A13. They contend that RSA 461-A:13 applies only when a nuclear family is absent; therefore, they argue, once they adopted C.W., the petitioners lacked standing to sue for grandparent visitation. We disagree.
Usually, in ruling upon a motion to dismiss, the trial court is required to determine whether the allegations contained in the petitioners’ pleadings are sufficient to state a basis upon which relief may be granted. In the Matter of Dufton & Shepard, 158 N.H. 784, 787 (2009). To make this determination, the court would accept all facts pleaded by the petitioners to be true and construe all reasonable inferences in the light most favorable to the petitioners. Id. When, however, the motion to dismiss does not contest the sufficiency of the petitioners’ legal claim, but instead challenges their standing to sue, the trial court must look beyond the allegations and determine, based upon the facts, whether the petitioners have sufficiently demonstrated a right to claim relief. Id. Because the underlying facts are not in dispute, we review the trial court’s decision de novo. Id. at 787-88.
Regarding the right of grandparents to petition for visitation, RSA 461-A.T3, I, states, in relevant part:
Grandparents, whether adoptive or natural, may petition the court for reasonable rights of visitation with the minor child as provided in paragraph III. The provisions of this section shall not apply in cases where access by the grandparent or grandparents to the minor child has been restricted for any reason prior to or contemporaneous with the divorce, death, relinquishment or termination of parental rights, or other cause of the absence of a nuclear family.
(Emphasis added.) We have construed this statute to authorize grandparents to petition for visitation “only when one of the conditions listed at the end of the second sentence has come to pass.” O’Brien v. O’Brien, 141 N.H. *630435, 437 (1996) (construing predecessor to RSA 461-A:13).1 Accordingly, under RSA 461-A:13,1, standing to seek visitation vests in a grandparent, whether natural or adoptive, whenever a grandchild’s family is the subject of one of the enumerated conditions listed at the end of the second sentence “unless the grandparent’s access to the grandchild has been earlier, or contemporaneously, restricted.” Id. Nothing in the statute divests a petitioning grandparent of standing when the child is subsequently adopted and becomes part of a new family unit. See RSA 461-A:13, I. When the legislature has clearly delineated the class that can petition to enforce a statutory scheme, we “will implement that determination meticulously.” O’Brien, 141 N.H. at 437. Here, because C.W.’s parents did not restrict the petitioners’ ability to visit C.W. “prior to or contemporaneous with” their deaths, their deaths conferred standing upon the petitioners to file for grandparent visitation. Accordingly, we conclude that the trial court did not err in refusing to grant the respondents’ motion to dismiss.
The respondents’ reliance upon In the Matter of Dufton & Shepard is unavailing. In Dufton, we noted that in O’Brien, “we explained that grandparent visitation rights existed only in the absence of the grandchild’s nuclear family.” Dufton, 158 N.H. at 788 (emphasis omitted). But in Dufton we were asked only to determine whether the term “grandparent” included a grandmother who had relinquished her parental rights to her daughter, the child’s mother. Id. at 787-88. We were not asked to consider the impact of a subsequent adoption or creation of a new family unit on a grandparent’s standing to petition for visitation.
Furthermore, we do not read Dufton as narrowly as do the respondents. The respondents argue that Dufton stands for the proposition that grandparents can petition for visitation if and only if a nuclear family is absent at the time of the petition. We disagree, and clarify that a grandparent’s standing to petition for visitation vests at the point when the statutory conditions are met. Here, those conditions were met when the child’s parents died. Absent statutory language to the contrary, subsequent creation of a new family unit does not divest a grandparent of the standing necessary to prosecute a petition. This interpretation comports with both our case law and the statute, which has no provision for terminating a grandparent’s right to petition for visitation. See, e.g., RSA 461-A:13; O’Brien 141 N.H. at 437.
*631Also unavailing is the respondents’ argument that permitting the petitioners to file for grandparent visitation after the adoption places adoptive parents in an unconstitutional “subclass” of parents. The statute does not target adoptive parents and has been relied upon by grandparents to petition for visitation when restricted by either adoptive or natural parents. See, e.g., In re Athena D., 162 N.H. 232, 234 (2011) (adoptive parents); In the Matter of Rupa & Rupa, 161 N.H. 311, 312 (2010) (natural parent); Dufton, 158 N.H. at 786 (natural parent); O’Brien, 141 N.H. at 436 (natural parent). Furthermore, we have long recognized that the rights of parents are natural, essential, and inherent rights to which great judicial deference must be accorded. Roberts v. Ward, 126 N.H. 388, 391 (1985). We have held that when a trial court applies RSA 461-A:13, it must weigh the first two statutory factors more heavily than the other statutory factors because, by so doing, the court accords deference to a fit parent’s judgment as to the child’s best interests. See Rupa, 161 N.H. at 318; see also RSA 461-A:13, 11(a), (b). This deference must be accorded to both natural and adoptive parents. See RSA 170-B:25,1 (2014) (considering an adoptee to be the child of the adopting parents and granting the adoptee all the rights and privileges, as well as all the duties and obligations, of a child born of the adopting parents). Because RSA 461-A:13 permits grandparents to seek visitation with both natural and adopted grandchildren and requires judicial deference to a natural or adoptive parent’s judgment, the statute does not place adoptive parents in an unconstitutional “subclass.” See Troxel v. Granville, 530 U.S. 57, 67 (2000) (plurality opinion) (holding unconstitutional, as applied, a third party visitation statute that accorded no judicial deference to parental decisions regarding the rearing of children). Accordingly, we conclude that the trial court did not err in denying the respondents’ motion to dismiss.
We next address the petitioners’ arguments regarding the trial court’s determination that continued court-ordered visitation was not in C.W.’s best interests. They argue that: (1) the trial court did not properly consider the fact that both natural parents died; (2) the trial court did not consider that, according to them, the respondents secretly adopted C.W. to eliminate their visitation rights; (3) the trial court erred by terminating visitation rather than modifying the visitation order; and (4) Troxel does not apply. We disagree.
The trial court has wide discretion in matters involving parental rights and responsibilities and we will not overturn its determination except when there has been an unsustainable exercise of discretion. See In the Matter of Bordalo & Carter, 164 N.H. 310, 313 (2012). When we review for an unsustainable exercise of discretion, we are deciding whether the record establishes an objective basis sufficient to sustain the discretionary judg*632ment made. State v. Lambert, 147 N.H. 295, 296 (2001). However, we review a trial court’s application of law to facts de novo. Bordalo, 164 N.H. at 314.
RSA 461-A:13, II requires, in relevant part, that the trial court consider the following criteria in making an order relative to a grandparent’s visitation rights:
(a) Whether such visitation would be in the best interest of the child.
(b) Whether such visitation would interfere with any parent-child relationship or with a parent’s authority over the child.
(c) The nature of the relationship between the grandparent and the minor child, including but not limited to, the frequency of contact, and whether the child has lived with the grandparent and length of time of such residence, and when there is no reasonable cause to believe that the child’s physical and emotional health would be endangered by such visitation or lack of it.
(d) The nature of the relationship between the grandparent and the parent of the minor child, including friction between the grandparent and the parent, and the effect such friction would have on the child.
(e) The circumstances which resulted in the absence of a nuclear family, whether divorce, death, relinquishment or termination of parental rights, or other cause.
(h) Any such other factors as the court may find appropriate or relevant to the petition for visitation.
We have recognized that trial courts must presume that fit parents naturally act in the best interests of their children. See Rupa, 161 N.H. at 318. Thus, trial courts must accord deference to the parents’ determinations with respect to the first factor in RSA 461-A13, II. A trial court cannot simply substitute its judgment for that of fit parents, regardless of whether those parents are natural or adoptive. Id.; see also Troxel, 530 U.S. at 69.
The petitioners first argue that the trial court erred in not according proper weight to the deaths of C.W.’s natural parents. In its order, the trial court sympathized with the plight of the petitioners but recognized that it must, “first and foremost,” consider the best interests of C.W. The trial court also concluded that consideration of the remaining four factors militated against court-ordered visitation, especially given that the respondents had “arranged regular and consistent visits with [C.W.] even before *633the court issued an order in that regard.” The petitioners have failed to establish that the trial court’s determination lacks an objective basis in the record or that it is legally erroneous. Accordingly, we conclude that the trial court did not unsustainably exercise its discretion when, after weighing the statutory factors, it denied the petition.
The petitioners next argue that the trial court failed to consider that the respondents obtained a “secret adoption” to deny them the ability to petition for visitation. The trial court made no finding that the adoption was in any way “secretive.” Moreover, the record does not establish that any aspect of the adoption proceeding undermined the trial court’s best interest determination.2
They next argue that the trial court erred in denying the petition instead of modifying the temporary visitation order. However, although they assert that modification was an option for the trial court, the petitioners fail to identify, and the record does not disclose, any evidence demonstrating that it was an unsustainable exercise of discretion for the trial court to deny the petition rather than modify the visitation order.
The petitioners conclude by arguing that the Supreme Court’s decision in Troxel does not apply in the present situation because both natural parents died and the visitation petition was filed before the adoption. As we have discussed above, Troxel accords natural and adoptive parents the same constitutional protections.
Accordingly, we conclude that the trial court did not err in denying the petition for grandparent visitation.
Affirmed.’
Dalianis, C.J., and CONBOY, Lynn, and BASSETT, JJ., concurred.In 2005, the legislature reorganized RSA Title XLIII and moved the section on grandparent visitation from RSA 458:17-d to the newly created RSA 461-A13. See Laws 2005, 273:1, :20. Thus, cases prior to 2005 discuss RSA 458:17-d. Nevertheless, those decisions control in interpreting and applying RSA 461-A:13.
We note that the petitioners were not entitled to notice of the adoption, see RSA 170-B:17 (2014); nonetheless, they acknowledge that they were notified of the respondents’ intention to adopt C.W. Nothing in the record demonstrates that the adoption was improperly conducted.