Yup, that suggestion was rubbish. Let's try again.
You need to keep the turn left variable the same while the range is short & flip it only when the turn has brought you to a clear path again.
So, keep an OldDistance variable with the prior value of distance. When OldDistance <=30 and Distance > 30, you've just finished a turn. At that point, you can flip turnLeft.