segments.py: corner-case bug fixed