Moved stat name assignment outside of loop