Corrects 'calculate_rate' to calculate average rate