update insert segment logic