use better function for looping over pids