optimize get_unread_topic logic