Add get_counter function.