fixed process wait bug