refactor conditional topic_header code