Counter implementation