Updated timeout logic