Yes, look at using a for loop. Replace the hardcoded indexes [0] etc with [i] where i is the for loop index.