fix bug to make UPSERT happen