Using arguments breaks the code

hello, im new to vex and i was assigned to do the autonomous period on a robot using a camera and an ultrasonic, so i did and it works!.
the problem is i need to do the same code for 4 other cameras and ultrasonics, so my solution was to edit the code so rather than it be void and take no argument ( moveToObject(void) ) to it taking several argument like camera , ultrasonic, and object needed to find (moveToObject(vision camera, sonar ultrasonic, signature obj) ) the only think i changed from the code is that rather than it taking Vision19.takesnap(Yellow) it would take camera.takesnap(obj) and the code was working until one method (liningUp() or liningUp(Vision camera, signature obj) ) where it always gets stuck on it .
the code that works (with no argument so it works on one camera and one object):-

void lining_up(){
  int screen_middle_x = 316 / 2;
   while (not is_lined()) {
        // snap a picture
        Vision19.takeSnapshot(Vision19__YELLOW_GOAL);
        
        // did we see anything?
        if (Vision19.objectCount>0) {
          // where was the largest thing?
          if (Vision19.largestObject.centerX < screen_middle_x - 60) {
            // on the right, turn right
            is_lined();
             Brain.Screen.printAt(1,80,"Turning Right");
             
            moveCar(0, 35);
          } else if (Vision19.largestObject.centerX > screen_middle_x + 60) {
            // on the left, turn left
            is_lined();
             Brain.Screen.printAt(1,80,"Turning Left");
             
            moveCar(0, -35);
          } else {
            // in the middle, we're done lining up
            Brain.Screen.printAt(1,80,"Stop");
            
            is_lined();
            moveCar(0, 0);
            break;
          }
        } else {
          // saw nothing, relax
          Brain.Screen.printAt(1,80,"found nothing sorry");
          
        }
      }

}

the code after adding the arguments
‘’’

void liningUp(vision camera2,signature obj ){
 Brain.Screen.printAt(1, 20, "function LiningUp");
  int screen_middle_x = 316 / 2;
   while (not  is_lined( camera2,  obj)) {
        // snap a picture
        camera2.takeSnapshot(obj);
        // did we see anything?
        if (camera2.objectCount>0) {
          // where was the largest thing?
          if (camera2.largestObject.centerX < screen_middle_x - 60) {
            // on the right, turn right
             is_lined( camera2,  obj);
             Brain.Screen.printAt(1, 180, "Turning Right");
            moveCar(0, 35);
          } else if (camera2.largestObject.centerX > screen_middle_x + 60) {
            // on the left, turn left
            is_lined( camera2,  obj);
             Brain.Screen.printAt(1, 180, "Turning Left");
             
            moveCar(0, -35);
          } else {
            // in the middle, we're done lining up
            Brain.Screen.printAt(1, 180, "Done lining up");
             is_lined( camera2,  obj);
            moveCar(0, 0);
            break;
          }
        } else {
          // saw nothing, relax
          Brain.Screen.printAt(1, 180, "found nothing");
        }
      }

}
‘’’
ps. the method is_lined return true when the object is centered and it works both times (checked on the screen)

the code just gets stuck on turning right all the time even when is_lined return true and when the object is on the left and will never break out of the loop

Can you paste the code for is_lined(), too? I don’t need to see the code from before.

Edit: Also, where specifically does the error come up? (Just copy the segment where the error is and point it.)

Edit 2: Maybe the problem is here:

Maybe you need to say void liningUp(vision camera, vision::signature obj) or even void liningUp(vex::vision camera, vex::vision::signature obj)? And when you call it… I’m not sure how you would specify which camera’s signature you’re talking about. Do you say Vision3.yellow_mogo or something when you want it to take a snapshot? Or maybe you just have to pass

I’ve never worked with vision sensors. I wish I could.