add insert_nth function.