Help please to improve this obstacle avoiding robot project.

Move this:

    turnLeft = !turnLeft;

into both the if blocks below it. i.e. only do it when you do a turn.