improved counter for logging