The phalanx was effective in large, open spaces, but not on the hilly terrain of the central Italian peninsula. In the 4th century, the Romans replaced it with the more flexible manipular formation. This change is sometimes attributed to Marcus Furius Camillus and placed shortly after the Gallic invasion of 390; more likely, it was copied from Rome's Samnite enemies to the south, following the Second Samnite War (326–304).