replaced series of cmds with a for loop