code for topic discovery