
950 So.2d 311 (2006)
T.D.P.
v.
D.D.P. and W.H.P.
2050098.
Court of Civil Appeals of Alabama.
August 4, 2006.
*312 Frances R. Niccolai, Mobile, for appellant.
W.A. Kimbrough, Jr., Mobile, for appellees.
PITTMAN, Judge.
T.D.P. ("the mother") appeals from a judgment determining that the mother's six-year-old daughter, A.N.P., and three-year-old son, W.H.P. (A.N.P. and W.H.P. are hereinafter collectively referred to as "the children"), were dependent and awarding custody of the children to their paternal grandparents, D.D.P. and W.H.P. ("the paternal grandparents"). We affirm in part and reverse in part.
On September 8, 2004, the paternal grandparents arrived at the mother's residence to return W.H.P. following a weekend visitation and discovered the residence to be in disarray and the refrigerator to be empty; the paternal grandparents immediately went to the Mobile County Department of Human Resources ("DHR") to request an investigation into the mother's care of the children. The next day, the mother was arrested for possession of a controlled substance and incarcerated.[1] On September 10, 2004, the paternal grandparents filed a petition with the Mobile Juvenile Court requesting temporary custody of the children due to the mother's situation; the juvenile court granted that petition the same day. In October 2004, the children's maternal grandparents filed a petition seeking to intervene in the pending custody action and requesting custody of the children; the trial court granted their petition to intervene.
The juvenile court conducted an ore tenus proceeding to consider the competing petitions for custody on January 27, 2005. One week later, the juvenile court entered a judgment finding that the children were dependent pursuant to Ala.Code 1975, § 12-15-1 et seq., and ordering the children's guardian ad litem to secure certain information regarding the interested parties, including home studies of both sets of grandparents,[2] school records of the children, and police records concerning the mother. Pendente lite custody of the children was continued with the paternal grandparents, but a dispositional hearing was scheduled for April 27, 2005.
At the April 27, 2005, hearing, the paternal grandfather, the maternal grandparents, the mother, and a family friend of the maternal grandparents testified and offered documentary evidence. The paternal grandfather testified that he and his wife had been awarded visitation with the children two years earlier, after the death of their son, the children's father. On October 21, 2005, the juvenile court entered *313 a judgment awarding custody of the children to the paternal grandparents. In that judgment, the maternal grandparents' petition for custody was denied, and the mother was awarded expanded visitation with the children (but the judgment required that the mother's visitation be supervised by the maternal grandparents); however, the juvenile court stated that because of the "extreme expense" involved in exercising visitation, the mother would not be required to pay child support to the paternal grandparents. The mother filed a timely postjudgment motion, and the juvenile court amended the judgment by clarifying the visitation schedule and awarding an attorney fee to the mother's court-appointed attorney. The mother appeals.
The mother challenges the juvenile court's determination of dependency and its award of custody of the children to the paternal grandparents. Initially, we note that when evidence is presented ore tenus, the trial court's judgment is presumed to be correct and will be set aside only if it is plainly and palpably wrong. Lucero v. Lucero, 485 So.2d 347, 348 (Ala. Civ.App.1986). A finding of dependency must be supported by clear and convincing evidence. Ala.Code 1975, § 12-15-65(f); see also M.M.S. v. D.W., 735 So.2d 1230, 1233 (Ala.Civ.App.1999). However, matters of dependency are within the sound discretion of the trial court, and a trial court's ruling in a dependency action in which evidence is presented ore tenus will not be reversed absent a showing that the ruling was plainly and palpably wrong. See, e.g., R.G. v. Calhoun County Dep't of Human Res., 716 So.2d 219, 221 (Ala.Civ. App.1998); G.C. v. G.D., 712 So.2d 1091, 1093 (Ala.Civ.App.1997); and J.M. v. State Dep't of Human Res., 686 So.2d 1253, 1255 (Ala.Civ.App.1996).
Alabama Code 1975, § 12-15-1(10)m., provides that a child may be declared dependent if he or she is "for any . . . cause . . . in need of the care and protection of the state." This subsection has been held to give the court the authority to declare a child dependent under the totality of the circumstances. Martin v. State ex rel. Alabama Dep't of Human Res., 502 So.2d 769, 771 (Ala.Civ.App. 1987); see also Kennedy v. State Dep't of Human Res., 535 So.2d 168, 170 (Ala.Civ. App.1988). The transfer of custody upon a finding of dependency is governed by the child's best interests. Jones v. Webb, 524 So.2d 374, 374 (Ala.Civ.App.1988).
The record reveals that the mother had a history of marijuana abuse. The mother admitted that she had lost her nursing license in October 2002 when she tested positive for THC (the chief intoxicant found in marijuana) during a work-related drug screening. The mother stated that the death of her husband followed shortly by the birth of W.H.P. had initially prevented her from getting proper treatment for her drug-dependency problem. She stated that she had completed an inpatient drug-treatment program at a facility called The Haven, but that she had been placed on a waiting list for several months before finally being accepted into a 12-week intensive outpatient drug-rehabilitation program. The mother testified that she was within a few weeks of completing that program, that she had not tested positive for any illegal drugs since the children had been removed from her home, and that she had already been hired to work at a local hospital as a nursing aide until she could petition the State Nursing Board to regain her nursing license later in the year.
The mother testified that, although she had been arrested on September 9, 2004, and charged with possession of illegal drugs, she had been informed by the local *314 district attorney that those charges would not be presented to a grand jury and had been dropped. She testified that the arresting officer told her that, upon further investigation, the officer had concluded that "they [were] in the middle of a domestic relations battle and [he] wished they had never got into it."
At the time of trial in 2005, the mother had been living in her recently deceased grandmother's house for approximately four months to prepare it for sale. The mother stated that, after completing that project, she wanted to obtain housing in the same school district that the children had attended when she and the children had previously lived with the maternal grandparents. The mother testified that although she had been working as a waitress at the time the children were removed from her custody, she had quit her job to concentrate on successfully completing the drug-rehabilitation program, which included mandatory meetings five nights a week. She opined that she would be a better caregiver than either set of grandparents.[3]
In contrast to the mother's testimony was the paternal grandfather's testimony regarding the living conditions of the trailer where the mother and the children were staying when the children were removed from the mother's custody by court order in September 2004. The grandfather testified that the mother's refrigerator was empty, that her residence was in disarray, and that, within 24 hours of discovering those conditions, the mother had been arrested for possible drug-related offenses. By the time of trial seven months later, the mother was unemployed and was involved in an intensive drug-rehabilitation program. Based upon the totality of the circumstances summarized above, we conclude that the juvenile court could properly have concluded that the children were dependent.
The mother also contends that awarding custody of the children to the paternal grandparents constituted an abuse of discretion. The only testimony regarding the paternal grandparents' ability to be custodians of the children was offered by the paternal grandfather. He stated that he and his wife lived in a one-bedroom camper that they had parked at Bay Resort Recreational Vehicle Park in Athens, Alabama, on a bluff overlooking the Tennessee River; he noted that their lot contained a steep drop of between 10 to 35 feet directly downhill to the river. The paternal grandfather opined that although there was a short wire fence that the children could easily step over, he did not believe the children could reach the edge of the bluff because it was 75 feet from the camper. He noted that his wife did not work outside the home unless she helped him run a concession stand that he owned and operated. Notably, although the paternal grandfather stated that he worked four days each week as a mobile-home escort driver, he did not offer any evidence of his monthly or annual income.
On the other hand, the paternal grandfather's testimony was seriously disturbing in several respects. When questioned about any prior arrests or convictions, the paternal grandfather admitted that he had been convicted of felony possession of illegal substances with intent to distribute.

*315 "Q: Have you ever been arrested?
"A: Yes, ma'am, I have.
"Q: Have you ever been convicted?
"A: Yes, ma'am, I have.
"Q: What were you convicted of?
"A: Possession with intent to distribute.
"Q: Is that a felony?
"A: Yes, ma'am, it is.
"Q: So, you can't vote?
"A: No, ma'am. . . .
"Q: How many times have you been arrested?
"A: One felony.
"Q: One felony, any other arrests?
"A: Traffic tickets, yes ma'am and uh, sales tax.
"Q: Sales tax what, evasion?
"A: No, ma'am. Failure to file. I didn't file them on time. I had some bad checks years ago. That's all I remember."
The paternal grandfather also admitted that on one occasion, when he and his wife had taken the children to his sister's house to be babysat, A.N.P. had been sexually molested.
"Q: Prior to your son's death, did ya'll babysit A.N.P. from time to time?
"A: Yes, ma'am, quite often.
"Q: Did members of your family babysit A.N.P. from time to time?
"A: Yes.
"Q: Okay are you aware of an incident where A.N.P. was sexually molested by being babysat by a member of your family?
"A: It was  yes, yes. My son told me that.
"Q: She was sexually molested when she was being babysat by your sister and her boyfriend; is that correct?
"A: My sister  boyfriend didn't do it. There was a child there that supposedly had done this. I mean a five or six year old baby.
"Q: But A.N.P. was being babysat by your sister and her boyfriend at the time; is that correct?
"A: Yes, ma'am. And she's been back out there since then. . . .
"Q: And have you  Have you, since you've had [custody of the children] have you left them with the boyfriend?
"A: Yes, ma'am.
"Q: You have?
"A: Yes, ma'am."
The record indicates that the fact that A.N.P. was sexually assaulted was not disputed. Regardless of the fact that neither the paternal grandfather's sister nor the sister's boyfriend had been charged with a crime, the paternal grandfather admitted that he continued to take the children to that sister's house and continued to allow her or her boyfriend to babysit the children on a regular basis.
The maternal grandparents' testimony was in sharp contrast to the paternal grandfather's testimony. The maternal grandfather stated that throughout the mother's marriage he and his wife had regularly babysat the children at their five-bedroom house. The maternal grandfather also testified that he was employed by the Mobile County Engineering Department, offered copies of his most recent paycheck, and noted that he would be allowed to add the children to his employer-provided health-insurance plan.
The maternal grandmother testified that she had been married to the maternal grandfather for 38 years; she noted that each child had his or her own room, toys, and clothes when staying with the maternal grandparents at their house. Because the mother and the children had lived with *316 the maternal grandparents for nearly a year following the father's death by drug overdose, the children had made numerous friends in the neighborhood. The maternal grandmother stated that she owned her own business and, therefore, possessed the ability to work flexible hours in order to spend time with the children. She noted that the mother's oldest child (from a previous marriage) had been living with the maternal grandparents during the school year because the child was a member of the local school's volleyball team and chorus. The maternal grandmother stated that she and her husband would provide stability in familiar surroundings for the children until such time as the mother completed her drug-rehabilitation program, rejoined the workforce, and petitioned the court for the return of custody of the children.
As noted previously, the overriding consideration in a child-custody case is the best interests of the children. See Jones v. Webb, supra; see also Jensen v. Short, 494 So.2d 90, 91-92 (Ala.Civ.App.1986). Factors to be considered by the trial court in determining what is in the best interests of the children include the sex, age, and health of the children; the children's emotional, social, moral, and material needs; and the custodial parties' ages, character, stability, health, and home environment. See Johnson v. Sparks, 437 So.2d 1308, 1309 (Ala.Civ.App.1983); see also Jensen v. Short, supra.
Based upon the testimony presented at trial, we cannot conclude that substantial evidence supports the juvenile court's determination that awarding custody of the children to the paternal grandparents was in the children's best interests. The evidence at trial established that the paternal grandparents do not live in a suitable residence conducive to support the activities and safety of small children. In addition, the paternal grandfather not only admitted that he was a felon, who had been convicted of possession of illegal drugs with intent to distribute them, but also that he continued to place his young granddaughter in serious personal jeopardy by repeatedly leaving her at a residence where she had been sexually molested on a previous visit. We conclude, therefore, that the paternal grandparents did not meet their burden of proof that the children's best interests would be served by their being awarded custody. Therefore, the juvenile court's judgment awarding custody of the children to the paternal grandparents is due to be reversed.
We affirm the juvenile court's judgment insofar as it determined that the children were dependent, and we reverse the judgment insofar as it awarded custody of the children to the paternal grandparents. The juvenile court must conduct another custody hearing and make a determination whether to return the children to the mother, with appropriate restrictions, or to place the children with the maternal grandparents.
AFFIRMED IN PART; REVERSED IN PART; AND REMANDED.
THOMPSON and BRYAN, JJ., concur.
CRAWLEY, P.J., concurs in the result, without writing.
MURDOCK, J., concurs in the result, with writing.
MURDOCK, Judge, concurring in the result.
I concur in the result. I write separately for the purpose of noting that on remand, the juvenile court, if it has not already done so while this case has been on appeal, must determine as a threshold matter whether the state of dependency that it found to exist in its October 21, *317 2005, judgment continues to exist. Based on the evidence presented at the last hearing conducted by the juvenile trial court, it certainly is foreseeable that the children no longer are dependent.
NOTES
[1]  Following a search of the mother's residence, the mother was arrested when the investigating officer discovered a pair of marijuana cigarettes in a bedroom.
[2]  The guardian at litem stated that he had been unable to procure home studies of either set of grandparents before trial.
[3]  We note that in October 2004, when the children's maternal grandparents filed their petition seeking custody of the children, the mother had signed an affidavit stating that she had no objection to the juvenile court's awarding temporary custody of the children to the maternal grandparents. Although the paternal grandparents assert that statement was an enforceable voluntary relinquishment of custody, the mother essentially revoked that statement by contending at trial that she would be the best custodian for the children.
