improved counting