Better upsertLogic