fix upsert bug