for loops performance improvement