Officials with the Springfield (KY) Police Department say that they believe the agency stopped a possible active shooter attack just moments before the heavily armed gunman approached his suspected target.

Police had responded to LB Manufacturing in Springfield after the department was called about a suspicious person in a vehicle nearby.

According to NBC News, police took 37-year-old Matthew Smith into custody outside of the building after Smith drew a weapon on an approaching officer.

Smith reportedly had three handguns on his person, as well as an AR-15 and two other rifles, along with more than a dozen magazines and ammunition.

During his arrest, Smith told officers he was "going to do what he needed to do" and suggested that he had been analyzing and studying the facility. The police chief said Smith knew which entrances to the building were open and which ones were closed.

Smith was charged with attempted murder of a police officer, first-degree wanton endangerment of a police officer, resisting arrest and third-degree criminal trespassing.