fix topic wait logic