refactored the pointer usage in insertPrincipalMetadata