Adding counter logic.