Fixed counting bug at levels greater than 1