slight performance improvement of for loops