# Problem in Pluto

Good evening to all,

I have a problem with my code. What I wrote is supposed to draw “lines” connecting the edge of the large rectangle with the edge of the small rectangle, like this:

But sometimes it gives me this, which is not normal:

My code is the following :

``````begin
using NativeSVG
using PlutoUI
end
``````
``````begin
const track = zeros(Integer, 49, 49)
track[1:2,1:49] .= -1
track[48:49,1:49] .= -1
track[1:49, 1:2] .= -1
track[1:49, 48:49] .= -1
track[12:38, 12:38].= -1
nothing
end
``````
``````function Map()
for row in 1:49
for col in 1:49
x = 20 + col * 12
y = 20 + row * 12
if track[row, col] === -1
rect(x = x, y = y, width = 12, height = 12, stroke = "transparent", fill = "black", stroke_width = "0")
else
rect(x = x, y = y, width = 12, height = 12, stroke = "black", fill = "transparent", stroke_width = "0.4")
end
end
end
end
``````
``````function Line()
Map()
a = rand(1:49)
b = rand(1:49)
a1 = 20 + a * 12
b1 = 20 + b * 12
if track[a, b] ≠ -1
if a == 3 || a == 39 && b ∈ (12 : 38)
while track[a, b] ≠ -1
a1 = 20 + a * 12
b1 = 20 + b * 12
rect(x = a1 + 1, y = b1 + 1, width = 10, height = 10, fill = "red")
a = a + 1
end
elseif a ∈ (12 : 38) && b == 3 || b == 39
while track[a, b] ≠ -1
a1 = 20 + a * 12
b1 = 20 + b * 12
rect(x = a1 + 1, y = b1 + 1, width = 10, height = 10, fill = "red")
b = b + 1
end
else
Line()
end
else
Line()
end
end
``````
``````Drawing(width = 700, height =700) do
Line()
end
``````

Do you know where the problem lies or even how to improve this code?
Thanks

In your code, it is not possible for Pluto to detect cell dependencies because all functions work by implicitly modifying the global `track` variable.
To make Pluto aware of the dependencies, use a more functional approach, i.e. `track2= Map(track)`, where `Map` takes their inputs as parameters and return the values they modified.
The initialization of `track` and `Line` are probably fine because they define / only read the `track` variable.