Finish insert function