now using list.index instead of looping over it