fixed upsert to handl updates and new inserts