Cleaned up the if statements for detecting the intersections