Remove duplicate code in topic()