fixed error in compareSegments()