trying to figure out loops for index