fix timeout code