added for loop inside a function.