Function call inside loop , small optimization