changed the way segments are build