Added Counter

added Counter and while loop