refactor check for first segment