add an optional callback to discoverNodes