handle empty segment more gracefully

Hi James,

I was getting a strange empty segment at one point, so I added this line. Not sure if it should be necessary. Would appreciate your thoughts on when total == 0 is allowable.

Jason