refactor Wait()