A man who federal agents say talked about joining ISIS and attacking random people to avenge a shooting at a New Zealand mosque has been arrested at a gun range in Montana.

Fabjan Alameti (FAB-yahn ah-la-MET-ee) appeared before a U.S magistrate judge Thursday to hear the charges of possession of a firearm by an unlawful user of a controlled substance and making false statements involving international and domestic terrorism.

FBI Special Agent Matthew Duermeier says in a sworn statement that Alameti moved to Bozeman last month from New York City. He had been communicating with a federal informant about traveling to join ISIS and planning a U.S. attack.

He was arrested Tuesday while renting a semi-automatic rifle at a gun range in Bozeman.

His federal public defender, John Rhodes, did not immediately return a call for comment Thursday.