refactor of segments