countUpTo function