Do something with GameObject with certain distance

I want to do something with gameobjects that are in a certain distance. The problem is, that my objects are stored in an intentory and therefor they are set unactive and active. I only want to perform the “do something” if both gameObjects (the one the script is attached to and the one that is in certain distance) are active.
My actual script does not work properly. It does all "do something"s automatically when the gameobject is set active. I hope someone can tell me the mistake or has an alternate solution.
kessel an holz are gameObjects that I identify with the itemID. I have all the Items stored in a database.

    void Update () {
    		GameObject[] items = GameObject.FindGameObjectsWithTag ("Item");
    		foreach(GameObject target in items) {
    				dist = Vector3.Distance(target.transform.position, transform.position);
    
    		}
    		if (dist <= 1 && gameObject.activeInHierarchy) {
    			for(int j = 0; j < database.items.Count; j++){
    				if (database.items[j].itemID == 1) {
    					if(holz.activeInHierarchy) {
    						//do something
    					}
    				}
    				if (database.items[j].itemID == 3) {
                                        if(kessel.activeInHierarchy) {
    					        //do something
    				        }
                                }
    			}
    		}
    	}

You could create a collider with trigger in the position where you want to check if there’s something and use tags to check that it’s the object you want.