ported over Sem from pma-v2