DES MOINES, Iowa (WHO) — A Des Moines man was arrested early Thursday morning in connection to a shooting that happened in July wherein he was the victim and a four-year-old was the shooter.

The shooting happened on July 23 at around 6:30 p.m. at an apartment in the 4400 block of East Philip Street. According to court documents, a four-year-old was able to gain access to a loaded firearm that was left unsecured on the floor of a bedroom closet, court documents state. The child fired the gun one time and the bullet went through the closet wall into the kitchen, court documents state.

Two other children, a 9-year-old and 2-year-old, were playing in the kitchen cabinets at the time of the shooting, court documents state. Joshua Kabe Goodwin, 28, who was also in the kitchen at the time, was hit in the leg by the bullet.

Goodwin was arrested and booked into the Polk County Jail early Thursday morning, but was later released. Goodwin has been charged with one count of child endangerment and a no contact order has been filed. A preliminary hearing has been scheduled for October 4th.