+ break loop when no new segment is generated
- removed debug comments/statements