I'm not entirely clear on your setup.
You have a sharp IR as your only sensor, right? I see you included scan_angle, but you have no code to move the sensor . . .
I'd do something like:
if (IR > thresh && scan_angle > 410)//sees something on left
else if (IR > thresh && scan_angle < 390)//sees something on right
else if (IR > thresh)//sees something in front
go reverse();//it will oscillate at the threshold here
if (IR < thresh)//doesn't see anything
else //sees something
Its a little bit more complicated than this, and you'll have oscillation issues for sure so you'll have to play around with it.