Modified code with timer-based rates