made the pid wait function nicer