another way to write for loop