replaced for loop to a command