added wait() in master thread