added autodiscover function