for loop solution