If you have added the GOSUB, then your code is now good.

You could always check if RawDist=0 then light an Error LED, that way you can check if you are actually getting sensible results back from your Sensor.