Extracted counter logic from activity