instantiateing GameObject relating on players position

I am trying to achive to load GameObject only if the player is 16 units from GameObjects position.

            function Update () {
	               if (player.transform.position.x > 16){
		                Instantiate(chunk1, Vector3(30, 0, 0), Quaternion.identity);
	}

}

but i have it in Update function so it keeps making new GameObjects if I am in that area.
and the instantiated object(s) is still there if I am not in that area. I dont have any more idea how to fix this.

this C# sample but should be easy to convert to JS:

 void Update(){
    	   distance = Vector3.Distance(target.transform.position, this.transform.position);
    		if(distance < 16f){
    			do something;		
    		}
    		if(distance > 16f){
    			do something else;
    		}
    	}
    }