It seems you're using the "distance" value incorrectly. A check for "distance < 500" doesn't make sense if earlier you defined "distance = miles / 500".
But since -in the format statement- you're multiplying by the distance value anyway,
you should ask yourself: How do you need to take the distance value into account in those "if" statements?