Updated the counter functionality code