added for loop functionality