What replaced/beat the phalanx/Legion?

by Everluck8

I know the phalanx was replaced by a better system (Legion), but what beat or replaced the roman legion?

How did it fall out of military war method/tactics?

tiredstars

On the subject of phalanx vs legion, you might be interested in this thread on that subject, in which /u/Iphikrates questions whether the phalanx really was inferior and whether it was replaced.