move rectangles with mouse and update lines dynamically