refactored into modules: -config, -discovery and -sample