fix timeout logic

Change-Id: I07035f279025f204a22dcf16354d1199f0ad9ea4