Refactor creation of segment by name