update stop distance algorithm