slightly cleaner variable usage for the total_segments function