better line connection logic and dragging