The United States should not have ended a special-operations task force in the southern Philippines three years ago in light of the weekslong jihadi siege of a city there, U.S. Defense Secretary Jim Mattis said Tuesday.

“In 2014, we canceled the named operation that we had down there, out of perhaps a premature view that we were gaining success,” Mattis testified before a Senate Armed Services subcommittee. “Without [the task force], we lost some of the funding lines that we would have been otherwise able to offer.

The city of Marawi on Mindanao Island has been under attack by Islamic State-linked militant groups for the past three weeks. Dozens of Filipino troops and civilians have been killed in the fighting.

On May 24, the day after the attack began, Philippine President Rodrigo Duterte declared martial law on the island.

In 2002, the U.S. opened a so-called “second front” on terrorism on Mindanao. Hundreds of special operations troops assisted the Philippine armed forces with training and surveillance through the Joint Special Operations Task Force-Philippines, which officially ended in 2015.

At the high-water point of Joint Special Operations Task Force-Philippines in 2010, about 600 special operators were working out of Camp Navarro, a high-walled base in Zamboanga, the island’s second largest city and the scene of numerous bombings and kidnappings for ransom.

A small number of U.S. special operators still rotating through the country have been assisting Philippine armed forces.

“We are working closely with them, the Philippines, for example, with both manned and unmanned aircraft as they try to retake Marawi there in Mindanao,” Mattis said.

The Philippines government had requested assistance by U.S. special operations in Marawi, a Special Operations Command Pacific spokeswoman said.

“For security reasons, we are not able to discuss specific technical details of U.S. support for ongoing [Armed Forces Philippines] operations,” Maj. Kari McEwen said in a statement.

The defunct task force’s mission “transitioned to rotational assignments of U.S. SOF based on close consultation with our AFP partners to appropriately tailor our approach to their requests,” she said. Special operators coordinate with their Philippine Security Force counterparts “to develop plans, mission essential task lists, measures of effectiveness and after action reviews.”

There are six separate “black flag” groups in the southern Philippines that have pledged loyalty to Islamic State, the jihadi group that controls parts of Iraq and Syria, a terrorism expert told a House subcommittee last month.

In addition, Abu Sayyaf, a jihadi group that had been largely decimated by U.S.-Philippine military cooperation, has staged a comeback, mounting 19 separate maritime incidents and taking of hostages between March 2016 and April 2017, Zachary Abuza, a professor at the National War College, told the subcommittee.

On Tuesday, Gen. Joseph Dunford, chairman of the Joint Chiefs of Staff, told the Senate subcommittee that the U.S. is also assisting the Philippines, as well as Malaysia and Indonesia, through the Maritime Doman Awareness Initiative in helping them understand the flow of foreign fighters between the Middle East and Southeast Asia.

Southeast Asian nations have also been incorporated into Operation Gallant Phoenix, which is a way of sharing intelligence that “allows us to take a trans-regional approach to violent extremism,” Dunford said.