Restricting mc movement

Hi

I have bit of code that shows the angle which my arrow is pointing, if i move my cursor the arrow changes and so does the text box displaying my angle…trouble is it goes 360 degrees and i want to restrict it from 0-180. any ideas?

Heres the code:

onClipEvent (mouseMove) {
x=this._xmouse;
y=this._ymouse*-1;
angle = Math.atan(y/x)/(Math.PI/180);
if(x<0){angle+=180}
if(x>=0&&y<0){angle+=360}
_root.angletext=angle;
_root.arrow._rotation=angle*-1;
updateAfterEvent();}