Improve get_pids