TERNI, Italy (AP) — Italy's plan to reduce the risk of a jihadi-inspired attack is pinned in small part on El Hacmi Mimoun, an imam who bikes to the prison in Terni every week and exhorts Muslim inmates not to stray from life's "right path" or hate people who aren't Muslim.

Seven inmates — three Moroccans, three Tunisians and a Somali — left their cells at Terni Penitentiary on an early summer day to listen as the Moroccan-born imam led prayers and delivered a sermon. Sunlight from a high barred window streamed through Mimoun's gauzy, off-white robe.

"If I am praying, I am not cooking up ideas to harm others on the outside," a 35-year-old Tunisian inmate said, sitting cross-legged in the small, beige-tiled room that was converted into the prison's Mosque of Peace.

None of the inmates would give their names, and prison rules precluded asking why they were serving time.

So far spared the attacks that have stunned France, Belgium, Britain and Germany, Italy has relied mostly on arresting and deporting suspected extremists to try to keep the country safe. But the Italian government has come to embrace prevention, too, especially in the prisons it doesn't want to become training grounds for potential extremists.

Inviting in imams who have been vetted to make sure they espouse "moderate views" is a tactic now being employed in Italian prisons to counter radicalization among inmates. In February, the government signed a recruiting agreement with the Union of Islamic Communities and Organizations in Italy, which professes to foster Islamic pluralism.

When preaching to inmates, "we stress that we are Italians of Muslim faith, Europeans of Muslim faith. ... We are 100 percent citizens with rights and duties," Union president Izzeddin Elzir said.

Italy's second generation of Muslim immigrants is just coming of age now. For the most part, the nation lacks neighborhoods with heavy concentrations of Muslim residents. But Muslims make up a disproportionate share of the population in Italy's prisons.

More than a third of all inmates in Italian penitentiaries are foreigners, and 42 percent of those come from the majority-Muslim countries of Morocco, Albania and Tunisia, according to a 2017 report by inmate advocacy group Antigone.

The advocacy group counted 411 chaplains but only 47 imams working in Italy's 200 prisons. Prison system officials worry that if imams don't make regular visits, inmates might be more vulnerable to the influence of those who are already radicalized.

"It's not so much those (inmates) who preach, but those who submit to this proselytizing" who are considered at risk, Terni Penitentiary Superintendent Natascia Bastianelli said.

Justice Ministry Undersecretary Gennaro Migliore stressed in an interview that of about 11,000 Italian prison inmates from predominantly Muslim countries, "those who could be potentially radicalized, or already radicalized don't exceed 400" inmates.

So far, 13 UCOII imams have started preaching in eight prisons after being screened by interior ministry officials. Government officials and the organization plan to evaluate the strategy's effectiveness as a de-radicalization tool this fall.

If Italy needed a wake-up call, it came with the morning news two days before Christmas.

Before dawn, officers in Milan confronted and killed a young Tunisian suspected of driving the truck that plowed through shoppers at a Berlin Christmas market that week, killing 12. Anis Amri is believed to have become radicalized during the 3 ½ years he spent in Italian prisons for his role in a riot at a migrant center.

In a separate case, authorities accused a Tunisian inmate with alleged links to extremist groups of recruiting fellow Muslims at an Italian prison and attacking inmates who resented his extremist propaganda.

Terni police commander Fabio Gallo said learning that Amri had spent time in Italian prisons spurred him and other prison officials to sharpen their skills at recognizing an inmate who is becoming radicalized.

About 20 percent of the penitentiary's personnel have taken courses to make them aware of possible signs, such as preaching to other inmates or exulting at television news coverage about extremist attacks in Europe, Gallo said.

But he stressed that it's often difficult to realize which words or gestures might be worrisome signals, especially for staff who don't understand Arabic. And inmates are catching on to what tips prison personnel off, Gallo said.

"Nobody has a long beard" anymore, the commander said.

Vetting imams may not prove to be a straightforward process either.

"Where do you set the bar? Is it OK if someone is saying Western society is decadent, but at the same time condemns ISIS?" asked Lorenzo Vidino, an Islamism expert.

Former anti-terrorism magistrate Stefano Dambruoso, who is now a lawmaker in Italy, endorses careful screening of who will be preaching to men and women behind bars. He thinks it's essential "they have been trained in schools, in environments respectful of the founding principles of our constitution."

Yet Dambruoso also expresses concern about the imams invited into prisons "turning into some kind of secret eye, or a spy for the institutions."

On the day when Mimoun was at Terni Penitentiary, 46 of the 109 foreigners in the medium-security section were from northern Africa. The imam delivered his sermon in Arabic, sprinkled with Italian and French phrases.

He said he teaches his followers to "respect Italians, respect neighbors, your colleagues, your cellmates." One of the inmates who came to pray in the mosque said that "if you respect religion, our religion, you won't commit" extremist attacks.

After the seven were accompanied back to their cells, Mimoun told of how an inmate once confided in him that he "hated Italians."

"I showed him in the Quran where it says you cannot hate others of different religions," the imam said.