It seems possible that `lineSegment.temp` will be undefined in which case `lineSegment.temp.length` will throw an error here. Maybe you meant to to just say `if (lineSegment.temp)` here?