Fix bug with repeated pids