Attempting to emulate unity editor style mouse look. Is jerky for some reason.

I want to able able to rotate my camera in a way very similar to the rotation achieved in the unity editor via holding down right mouse button and dragging. I have code that comes close, but it is VERY jerky, to the point where it is pretty unusable.

Here is my code:

var startMousePosition : Vector3;

function Update () {	

// set camera movement speed reference point.
if(Input.GetMouseButtonDown(1) || (Input.GetMouseButton(1) && (Input.GetAxis("Mouse X") == 0 && Input.GetAxis("Mouse Y") == 0))) {
	startMousePosition = Input.mousePosition;
}

// move camera
if(Input.GetMouseButton(1)) {			    	   	    
	
    var difference : float = Vector3.Distance(Input.mousePosition, startMousePosition); 	    
    
    //x rotation	    
   	if(Input.GetAxis("Mouse X") != 0) {
	    if(Input.mousePosition.x < startMousePosition.x) {
	    	difference = -difference;
	    }
	    Camera.mainCamera.transform.RotateAround(Vector3.zero, Vector3.up, Mathf.Lerp(0, difference * 4, Time.deltaTime));
	}
				    
    //y rotation
    if(Input.GetAxis("Mouse Y") != 0) {
	    if(Input.mousePosition.y > startMousePosition.y) {
	    	difference = -difference;
	    }
	    Camera.mainCamera.transform.RotateAround(Vector3.zero, Camera.mainCamera.transform.right, Mathf.Lerp(0, difference * 4, Time.deltaTime));
	}
}        			
}

How could I make this smoother? I am open to doing this via a different method too (I was unable to find code that already does this surprisingly enough).

I clearly over-complicated this. This is the new code that works:

function Update () {	

if(Input.GetMouseButton(1)) {
    Camera.mainCamera.transform.RotateAround(Vector3.zero, Vector3.up, Mathf.Lerp(0, Input.GetAxis("Mouse X") * 400, Time.deltaTime));
    Camera.mainCamera.transform.RotateAround(Vector3.zero, Camera.mainCamera.transform.right, Mathf.Lerp(0, -Input.GetAxis("Mouse Y") * 400, Time.deltaTime));
}        			
}