A 27-year-old man was charged Thursday with child abuse homicide after he fell asleep with a loaded gun close by and his 2-year-old fatally shot himself with it.

Tasman William Maile told police officers he falls asleep every night with his gun “fully loaded and off safety, within arm’s reach.” On May 26, as he slept in his West Valley City home with his two children, Maile woke up to the sound of a gunshot, according to court documents filed Thursday in Third District Court.

Police later found the 2-year-old on the floor unconscious, a Walther CCP handgun nearby.

The child died at the hospital three days later.

In investigating the shooting, officers reportedly also found evidence of a marijuana-selling operation, according to court documents.

The documents allege that, in the moments after the shooting, a neighbor saw Maile run outside with his older son and throw a blue bucket into a dumpster. When police searched through the trash, they found a blue bucket containing a handgun magazine and two glass jars with more than 10 ounces of marijuana inside, as well as a digital scale.

Police also found a backpack with an empty gun case for a Walther CPP inside and two other handguns, according to the documents.

Salt Lake County District Attorney Sim Gill said prosecutors weighed several factors in the case before deciding to file a child abuse homicide charge. The information prosecutors received in the case — such as how Maile stored his gun — indicated criminal negligence caused the child’s death, Gill said.

“This is a little bit different than somebody who takes their weapon and puts it in a case up in the closet somewhere, hidden behind the clothes, and some child inadvertently finds it and shoots themselves,” he said.

Maile also was charged with obstruction justice, a third-degree felony, three counts of possessing a firearm by a restricted person, also third-degree felonies, and possession of a controlled substance with intent to distribute, a class C misdemeanor .