   LANGUAGE plpgsql
   AS $$
     BEGIN
-    PERFORM rebuild_explicit_cites_listing_for_node(NULL);
+      PERFORM rebuild_explicit_cites_listing_for_node(NULL);
     END;
   $$;
 

  LANGUAGE plpgsql
  AS $$
    BEGIN

    UPDATE taxon_concepts SET listing = COALESCE(listing, ''::HSTORE) ||
      HSTORE('species_listings_ids', q.species_listings_ids)
    FROM (
      SELECT taxon_concept_id, ARRAY_AGG(species_listing_id) AS species_listings_ids
      FROM listing_changes
      INNER JOIN change_types
      ON change_type_id = change_types.id
        AND change_types.name = 'ADDITION'
      INNER JOIN designations
      ON change_types.designation_id = designations.id
        AND designations.name = 'CITES'
      WHERE is_current = TRUE
      GROUP BY taxon_concept_id
    ) AS q
    WHERE taxon_concepts.id = q.taxon_concept_id AND
    CASE WHEN node_id IS NOT NULL THEN taxon_concepts.id = node_id ELSE TRUE END;

    UPDATE taxon_concepts SET listing =
    CASE

      hstore('cites_listing_original', ARRAY_TO_STRING(
        -- unnest to filter out the nulls
        ARRAY(SELECT * FROM UNNEST(
          ARRAY[listing -> 'cites_I', listing -> 'cites_II', listing -> 'cites_III']) s
          WHERE s IS NOT NULL),
          '/'
        )
      ) AS listing
      FROM (
        SELECT taxon_concept_id,
          hstore('cites_I', CASE WHEN SUM(cites_I) > 0 THEN 'I' ELSE NULL END) ||
          hstore('cites_II', CASE WHEN SUM(cites_II) > 0 THEN 'II' ELSE NULL END) ||
          hstore('cites_III', CASE WHEN SUM(cites_III) > 0 THEN 'III' ELSE NULL END)
