Put in a function to calculate the timeout interval.