improve line intersect check