refine counter updating