Rearrange the timeout logic to be a little more efficient