moved comment removal before the loop