BILLINGS, Mont. (AP) — A man has pleaded guilty to shooting at people in the streets of Billings and later at a state park.

The Billings Gazette reports  that 53-year-old Kelly Dee Megard admitted to felony assault with a weapon and four charges of felony criminal endangerment as part of a plea deal Thursday.

Prosecutors say Megard was under the influence of methamphetamine and believed people were trying to kill him when he followed a man while pointing a gun at him in July 2014. Later the same day he fired shots at a woman traveling with her two children in Billings before ramming her SUV with his car. He was arrested while shooting at bushes and people in Pictograph Cave State Park.

He can withdraw his pleas if the judge exceeds the sentence recommended in the plea agreement.