move declarations to outside of 'for'