wrong counting function