minor adjustments to loop