mouse look code problem

I came across this code and tried it out. I have been struggling with mouse look for quite some time and this one actually works, but the character only moves in circles instead of going in the direction of the mouse. Why is this? Here’s the code.

import Rasterizer as r
import GameLogic as gl
import mathutils as m
import math
cont=gl.getCurrentController()
own = cont.owner
sensUPDOWN=.0009
sensLEFTRIGHT=.0009
mouse=cont.sensors[‘Mouse’]
updown=cont.actuators[‘updown’]
leftright=cont.actuators[‘leftright’]
pivot = gl.getCurrentScene().objects[‘cam_pivot2’]
#r.showMouse(True)

extract width and height from gameScreen

width = r.getWindowWidth()
height = r.getWindowHeight()

distance moved from screen center

x = int(width/2) - mouse.position[0]
y = int(height/2) - mouse.position[1]

#New stuff
#grabbing vectors
orient = pivot.localOrientation
orientz = [orient[0][2], orient[1][2], orient[2][2]]
vec1 = m.Vector(orientz)
#print(dir(m.Vector))
par = pivot.parent
par2 = par.parent
parOrient = par2.orientation
parOrientz = [parOrient[0][2], parOrient[1][2], parOrient[2][2]]
vec2 = m.Vector(parOrientz)
angle = math.degrees(vec1.angle(vec2))
r.setMousePosition(int(width/2), int(height/2))
leftright.dRot=[0,0,xsensLEFTRIGHT]
cont.activate(leftright)
if angle < 160 and angle > 20:
updown.dRot=[y
sensUPDOWN,0,0]
cont.activate(updown)
elif angle > 160 and y < 0:
updown.dRot=[ysensUPDOWN,0,0]
cont.activate(updown)
elif angle < 20 and y > 0:
updown.dRot=[y
sensUPDOWN,0,0]
cont.activate(updown)
else:
cont.deactivate(updown)
#works in 2.57

Here’s the attachment.
[ATTACH]144232[/ATTACH]