Is this Auton code correct?

Is this Auton code correct? We accidentally put our SOnar Sensor upside done and I think that might be the reason but for some reason it kept making our arm go up. Again, the reason for that would have probably been the Sonar sensor being upside down.

void autonomous( void ) {
while(Sonar1.distance(distanceUnits::in) <8)
{
Arm1.spin(vex::directionType::fwd,200, vex::velocityUnits::pct);

}
while(Sonar1.distance(distanceUnits::in)>8)
{
Frontleftmotor.spin(vex::directionType::fwd,200,vex::velocityUnits::pct);
Backleftmotor.spin(vex::directionType::fwd,200, vex::velocityUnits::pct);

Backrightmotor.spin(vex::directionType::fwd,200, vex::velocityUnits::pct);
Frontrightmotor.spin(vex::directionType::fwd,200, vex::velocityUnits::pct);
}
Frontleftmotor.stop();
Frontrightmotor.stop();
Backleftmotor.stop();
Backrightmotor.stop();

The code looks mostly correct but there are a couple minor problems.

Why are you running the motors at 200 percent? I don’t think that makes them go faster. If you wanted, you could say vex::velocityUnits::rpm I believe and change speed by rotations per minute.

If the the sonar sensor reached exactly 8 in the previous if statement, then this code would never run. I might say greater than or equal to ( >= is the operator). Not sure if that would ever be a problem though. If the arm is going the wrong direction, then you could set the direction type to rev and that might fix it.