Made a time out a function of the number of events