break out of loop if index is found