Move PID retrieval into a separate function
Properly find the primary data PID for metadata posting