version 2 with for loop