change insert algorithm