created for loop based on user input