Can you provide a minimal reproducible example? Because for me the above code works just fine even for a hundred segments.