the bug was with the pid array. Need to figure out a diff way to do this