start of insert fn