change insert to upsert: update or insert