Done. Also switched to using `constructUpsertQuery`