Change to wait instead of waitpid