converted indexing loop to match Bens.