Fixed counting bug