Problem With Counting Broken Objects.

so i have a code for counting broken boxes in a game and it gives me a null refrence exeption on line 29. it also sometimes glitches out or whatever and doesnt count a broken box even though it has the “counted” tag on it, i dont know if these two issues are related to each other but i am now just putting a static on the variable as you can see so that i can unlock certain areas to the player using this count and if it is not acurate…(p.s. most of the stuff below is for asthetics as it looks better this way):

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class boxesbroken : MonoBehaviour {
    public Text CounterText;
    private int count;
    [HideInInspector]
    public static int boxbreak;
    void Start()
    {
        count = 0;
    }
	void Update ()
    {
        GameObject[] objects = GameObject.FindGameObjectsWithTag("broken");
        boxbreak = count;
        foreach (GameObject obj in objects)
        {
            count++;
            obj.tag = "counted";
        }
        if (count<1000)
        {
            if (count < 100)
            {
                if (count < 10)
                {
                    CounterText.text = "00" + count.ToString();
                }
                else
                {
                    CounterText.text = "0" + count.ToString();
                }
            }
            else
            {
                CounterText.text = count.ToString();
            }
        }
    }
}

and also this is my first real project in unity so go easy on me if it is very obvious.
thanks!

ok… for some reason it just fixed itself (both errors)and i didn’t do anything to it. i didn’t modify the script there at all. interesting. if anyone can tell me why so i can understand this, that would be great and very appreciated.