Ok I went ahead and changed what you suggested thanks for the reply it seems to fixed some stuff and now the servo motor rotates all 180 degrees but not following any set number from the sensor would it have something to do with the mapping numbers being to large of numbers? and this is the new void loop section
void loop(){
digitalWrite(trig, HIGH);
delayMicroseconds(10);
digitalWrite(trig, LOW);
duration_us = pulseIn(echo, HIGH);
distance_cm = 0.017 * duration_us;
Serial.print("distance");
Serial.print(distance_cm);
Serial.println("cm");
distance_cm = analogRead(A0);
distance_cm = map(duration_us, 0, 1023, 0, 255);
myServo.write(distance_cm);