Parent waits for the correct child to finish
fixed the slow terminal problem