public void rotateAndPoll(int flagColor){
		initialHeading = robot.getHeading();//get the initial heading of the robot
		boolean foundFlag = false;
		while (true) {
			int distance = getFilteredData();
			//LCD.drawString("Angle           ", 0, 2);
			//LCD.drawString("Angle " + robot.getHeading(), 0, 2);
			LCD.drawString("No Object Detected", 0, 0);
			LCD.drawString("          ", 0, 1);

			robot.setRotationSpeed(30);
			if (robot.getHeading() - initialHeading >= 360) {	//if the robot has rotated and polled 360 degrees
				//LCD.drawString("Angle f   " + (robot.getHeading() - heading), 0, 2);
				break;
			} else{
				distance = getFilteredData();	//update distance
			}
			if (distance <= 23) {	//if the robot is close enough to reliably detect the object
				LCD.drawString("Object Detected   ", 0, 0);
				double firstHeading = robot.getHeading();
				 distanceToObject =0;
				//int correctionAngle = computeCorrectionAngle(distance);
				//robot.setRotationSpeed(0);
				while(distance <= 23){
					//robot.setRotationSpeed(30);
					distance =getFilteredData();
				}
				double secondHeading = robot.getHeading();
				int angle = computeAngle(firstHeading,secondHeading);
				robot.rotate(-angle);
				if(distance > 10){
					distanceToObject =getFilteredData()-10;
				}
				navigation.goForwardWithoutPolling(distanceToObject);
				if(doObjectDetection() == flagColor ){
					LCD.drawString("Flag     ", 0, 1);
					foundFlag = true;
					break;
				}
				else{
					navigation.backtrack(distanceToObject);
					distance = getFilteredData();
					while(distance <= 23)
					{
						robot.setRotationSpeed(30);
						distance = getFilteredData();
					}
				}

			} else {
				distance = getFilteredData();	//update distance

			}
		}

		robot.setSpeeds(0,0);
		if(foundFlag){
			capture();
		}
	}