tried fixing line intersection algorithm