Initial version with discover function