Camera to stop when there is enemy, but move with player when there is not.

I am attempting to make my camera lock position when a gameObject tagged “Enemy” is found, but after enemies are destroyed, to move along with player.
Code:

var target : Transform;
var distance : float;
var speed : float = 1;
var EnTarget : Transform;
var tracking : boolean = false;
function Update(){
 if (!target){
     target = GameObject.FindWithTag("Player").transform;
}
 if(target.transform.position.z > Camera.main.transform.position.z+150){
    transform.Translate(Vector3(speed,0,0));// = target.position.z+170 -distance;
}      
 if(!EnTarget){
    EnTarget = GameObject.FindWithTag("Enemy").transform;
}
 if(EnTarget != null){
    tracking = true;
}else{
    tracking = false;
}
 if(tracking == true){
    speed = 0;
}
 if(tracking == false){
    speed = 2;
}
}  

It works perfectly as far as following the player, but when an enemy is found, it permanently locks, even after there are no enemies.

Turns out, it was a simple error. I was calling for the transform of the EnTarget variable, instead of checking if it just existed. Taking .transform off of the
target = GameObject.FindWithTag("Player").transform;
and changing the typecast to GameObject instead of transform did it.