fixed exit and wait