Need help with disconnecting events

I want it so when the mouse exits the gui object the event connection breaks

but right now if I mouse leave fast the event doesn’t disconnect

if v.Name == "Bundle1" or v.Name == "Bundle2" or v.Name == "Crates" then 
			v.InputBegan:Connect(function()
			
				connection = runService.RenderStepped:Connect(function()
					if viewportFrame ~= nil then 
						local worldModel = getWorldModel(viewportFrame)
						local Model = worldModel:FindFirstChild("Handle")
						if Model then 
							Model.CFrame = Model.CFrame * CFrame.fromEulerAnglesXYZ(0, 0.01, 0)
						end
					end
				end)
			end)
			
			v.InputEnded:Connect(function()
				connection:Disconnect()
				
			end)
		end

if v.Name == "Bundle1" or v.Name == "Bundle2" or v.Name == "Crates" then
    local Connection;
    v.InputBegan:Connect(function()
        Connection = runService.RenderStepped:Connect(function()
            if viewportFrame ~= nil then 
                local worldModel = getWorldModel(viewportFrame)
                local Model = worldModel:FindFirstChild("Handle")
                if Model then 
                    Model.CFrame = Model.CFrame * CFrame.fromEulerAnglesXYZ(0, 0.01, 0)
                end
            end
        end)
    end)

    v.InputEnded:Connect(function()
        if Connection then
            Connection:Disconnect()
        end
    end)
end