edit counter function