Calculate timeout correctly