Need help with animation


As you can see in this broken animation, the legs spread out when i rotate the torso. Anyone have any idea how to fix this?

Only solutions I have thought of is animating the legs every frame and manually correcting it, but I am looking for other solution as that is very time consuming.