implemented Wait()