upsert code fix