use range-based loop where possible