Coding Turns with the Inertial sensor vex code

Hey all

My team has been trying to code more accurate turns using the inertial sensor, but i’m thoroughly unfamiliar with how the thing works. I’ve tried to built a simple function based on the position of the inertial to stop a right turn when it reaches a certain value, but when it’s called the robot either does nothing or spins forever. I currently am not using the variable D but instead have 90 plugged in as the angle value. Could someone explain exactly how to make this thing work?

double d;
void turnInertial(){

// Turns the robot to the right
 LDrive.spin(directionType::fwd, speed, velocityUnits::pct);
 LDrive2.spin(directionType::fwd, speed, velocityUnits::pct);
 RDrive.spin(directionType::rev, speed, velocityUnits::pct);
 RDrive2.spin(directionType::rev, speed, velocityUnits::pct);
 // Waits until the motor reaches a 90 degree turn and stops the Left and
 // Right Motors.
 waitUntil((Inertial.rotation(degrees) >= 90.0));
RDrive2.stop(brakeType::hold); wait(1, seconds);