use range based for loop

Use range based for.