Simple index out of range question?

Hello guys I have a very simple problem here:

 var x = Input.touches[0].deltaPosition.x * rotateSpeed * Time.deltaTime;

its a line of a code that orbits around my character, but it throws the error “index out of range”, I figured out that it was because Input.touches[0] can be exceeded but how can I prevent my code from doing that?

something like: if(Input.touchCount > 0){here something}
probably?

Yes, the simplest solution would be to wrap this in a check, like

if ( Input.touches.Length > 0 ) {
    var x = Input.touches[0].deltaPosition.x * rotateSpeed * Time.deltaTime;
    // .. more code
}