refactor of segment/edge structure