total_duration -> accumulated_duration, swapped if else