added some line intersection checks