run discovery code in a  loop