added reverse counter logic