code refactored, duplicate code removed on new_topic and new_reply hook