Refactor segments