more generic method for extracting PID of current