Made general functions for insert_node and for update_node.