add null check to make sure counters do not get increased incorrectly