fixed waiting for child processes