code style: optimize for loop