introduce new function is_pid_hidden and call it instead of duplicating code