WHat you need to do, is each loop reset the pitch angle of the camera to zero, move the camera back or forward, depending on the mouseZ value, then point the camera at the cube.
In that order. It should work fine :)
In that order. It should work fine :)