sleep replaced by wait