update wrong comment
replace counting loop with range-based loop
remove unused variable
fix wrong comment