Fixed wrong segment being selected when segment count is smaller than 7