final edition before adding code to deal with line intersections
first implementation of trying to avoid lines intersections
after merging