Twisted loft between two meshes c++

Hello,

I’m trying to create a loft surface between two meshes, given two contour curves (ON_Curve).
Here’s the loft parameters:

   CArgsRhinoLoft args;
   args.m_bAllowStartTangent = false;
   args.m_bAllowEndTangent = false;
   args.m_bUseStartpoint = false;
   args.m_bUseEndpoint = false;
   args.m_bClosed = false;
   args.m_loft_type = CArgsRhinoLoft::ltTight;
   args.m_simplify_method = CArgsRhinoLoft::lsNone;
   args.m_start_condition = CArgsRhinoLoft::leNatural;
   args.m_end_condition = CArgsRhinoLoft::leNatural;
   args.m_rebuild_point_count = 50;
   args.m_refit_tolerance = RhinoApp().ActiveDoc()->AbsoluteTolerance();

      CRhinoLoftCurve* loftCurve = new CRhinoLoftCurve;
      loftCurve->m_curve = onCurve->DuplicateCurve();
      loftCurve->m_curve->RemoveShortSegments(ON_ZERO_TOLERANCE, true);
      loftCurve->m_pick_point = ON_UNSET_POINT;
      loftCurve->m_pick_t = ON_UNSET_VALUE;
      loftCurve->m_trim = 0;
      loftCurve->m_bClosed = loftCurve->m_curve->IsClosed() ? true : false;
      loftCurve->m_bPlanar = loftCurve->m_curve->IsPlanar(&loftCurve->m_plane)? true : false;
      args.m_loftcurves.Append(loftCurve);

   ON_SimpleArray<ON_NurbsSurface*> loftedSurfaceList;
   bool isLoftSucceeded = RhinoSdkLoftSurface(args, loftedSurfaceList);
   if (!isLoftSucceeded)
   {
      return;
   }

   if (loftedSurfaceList.Count() > 1)
   {
      return {};
   }

   auto* loftedLeg = loftedSurfaceList[0]->CreateMesh(ON_MeshParameters::FastRenderMesh);
   if (loftedLeg == nullptr)
   {
      return ;
   }

The resulting loft surface seems to be twisted around as seen in the photo below:
image

Any idea on why is this is happening? thank you

check curve direction and loft seams (usually start position of the curve or polycurve)