SFPD / San Francisco Police Department

The driver killed in his vehicle on Polk Street in San Francisco on Saturday was accidentally shot by a drunken friend who was swinging a loaded gun in the back seat of the car, according to a court filing by the San Francisco district attorney’s office on Wednesday.

Victor Sosa, 23, was driving his friends around in his Toyota Corolla after leaving a local bar. Inside the car were two passengers: an unnamed woman in the front passenger seat and the defendant, Jose Beltran, 32, in the back driver’s side seat. The three friends were looking for a place to buy more alcohol and ended up in the Tenderloin near Polk Street, according to the filing.