Implement insertion function for the DAG