refactor the counting loop command